6 ms·
While from what I have read about it zsh is a nice shell, it doesn't deal with what I find to be the biggest problem with bash, sh, and just about every shell t
by LeafStorm 15y ago
While from what I have read about it zsh is a nice shell, it doesn't deal with what I find to be the biggest problem with bash, sh, and just about every shell that isn't fish: the horribly ugly and inconsistent syntax. And I think it's rather sad that on what is supposedly the most advanced shell of our generation, you still have to deal with a thousand ridiculous redirections and quoting styles, different delimiter keywords for every control structure ("fi?" "done?" "esac?" Why not just freaking "end?"), and rules for expanding variables that come back to bite you in the rear whenever you have spaces, quote characters, or anything besides a run of letters, numbers, and a select few punctuation marks in your filenames or other variables.
- googletron 15y agoI think your complaining more about shell scripting rather than the terminal use itself.
- ismarc 15y agoI think you're underestimating how frequently some folks do things like: for x in 'seq 1 100'; do echo "something with $x"; done (Please forgive lack of backticks on my cellphone keyboard) Or many variations, like every line in a file, or result of a command piped to sed or awk and then processed. Init scripts are about the only shell scripts I write anymore, but I use frequently use it from the commandline, typically on remote terminals.
- fluidcruft 15y agoJust forget backticks even exist. I now always use $(cmd) instead of `cmd`. Much easier to read and it fits in better with process substitution <(cmd). More importantly it all nests sanely $(cmd1 $(cmd2)) and works well in quotes "Blah: $(cmd1 $(cmd2))".
- deleted 15y ago[deleted]
- kruhft 15y agoOnce you learn the zen of shell script, like any programming language, those problems pretty much go away. Shell script is a tiny language packed with features and can be learned through constant use in a week, but like any language, it takes time to master. It's incredibly powerful for interactive use and data manipulation combined with the standard Unix tools and sometimes pulling out perl or python is more work than just banging out a pipeline on the command line. Quoting does take some time, but just remember that when in double to quote your variable expansions with double quotes. There's more too it, but that's a good rule to start with.
- jlebar 15y agoMaybe I lack the proper zen, but I haven't found this to be true at all. Here's a good bash FAQ. It contains questions like "how do I use associative arrays", with answers like "this is a complex question." I don't even have to ask in any half-decent scripting language. http://mywiki.wooledge.org/BashFAQ/ http://mywiki.wooledge.org/BashFAQ/
- kruhft 15y agoI reccommend ksh over bash. That's all I use these days. It was sh done right, although it does have a bit of history to it for compatibility. To use associative arrays in ksh: typeset -A table column="name" table[$column]="value" echo ${table[$column]} ksh is much more decent than bash, although I reccommend using in an emacs M-x shell buffer for better command line editing. Edit: forgot to dereference column when setting value in table.
- Lewisham 15y agoThe thing I like about fish is the easy history nav. I type "git" and press Up, and I get to go through my history of anything that started with "git" very quickly. I'll often remember I typed an svn command three weeks ago, but forget the parameters, and I'll have it back within 15 seconds. It's like magic!
- CJefferson 15y agoThis is indeed a lovely feature I couldn't live without. In bash, you can get it by adding the following to your .inputrc (at least on mac terminal) "\e[B": history-search-forward "\e[A": history-search-backward
- deleted 15y ago[deleted]
- ohgodthecat 15y agoI believe in bash and zsh the default is ^R and ^S
- shabble 15y agoexcept a huge number of terminal emulators still reserve ^S/^Q for XON/XOFF software flow-control[1]. stty -ixon lives in my init scripts for that reason. [1] https://en.wikipedia.org/wiki/Software_flow_control https://en.wikipedia.org/wiki/Software_flow_control
- sandGorgon 15y agoin zsh you get it by adding bindkey "^[[A" history-beginning-search-backward bindkey "^[[B" history-beginning-search-forward
- gkop 15y agoI add these lines so the left- and right-arrows still work correctly: "\e[C": forward-char "\e[D": backward-char
- deleted 15y ago
- ramLlama 15y agoI have been using fish for several years now. It's community is a fraction of zsh, bash, and others, and I've tried to go back to them, mostly out of misplaced "everyone else is doing it" mindset Fish is a great shell. It's a modern shell, that uses colors, UTF, and processing power that didn't exist when the others were designed. I feel the best thing about it is the sane defaults and large number of prebuilt completions. For any other shell, I have to dive into bashrc's and esoteric commands to get what I want. Fish just does what I want. It's made me far more productive, and for that, it gets my best shell award. Its scripting support is good, very similar to other shells. Yes, the syntax is non-compatible, and not even POSIX. But, it makes more sense. Besides, for anything except the simplest of scripts, I use lua. I doubt you'd want to use bash to do something very complicated. Some people want their shell scripts to be compatible and do a lot of cool things. I feel that the days of a shell being used for scripting are past. For me, a shell is a way of interacting with the system. Fish does this really well. Scripting is a slight afterthought, as it should be.
- mixmastamyk 15y agoSame here, the syntax highlighting rocks (I couldn't go back now), and I do like the shared history. For simple non-interactive scripts I still use bash because of its ubiquity, python for complex needs.
- pyre 15y ago> I do like the shared history. Maybe the implementation is different, but ZShell has shared history. (Just noting that this is not a 'fish rocks other shells because of X' feature)
- mixmastamyk 15y agoYep, this thread is currently under several comments talking/complaining about zsh shared history. I'm in the "appreciate" camp.
- andrewflnr 15y agoDo you have to do anything weird to Lua to make it work as a system scripting language? Do you just use the built in OS interfaces?
- jff 15y agoTry Plan 9's "rc". It has a more C-like syntax, so you write things like "for (i in `{seq 1 100}) { echo $i }"; I really enjoy writing in rc.
- naner 15y agoHow is that better than bash or zsh: for i in `seq 1 100`; do echo $i; done zsh: for i in `seq 1 100`; echo $i
- nimrody 15y agoIt's sort of ok when its `do... done`. But what about `if`..`fi` or `case`..`esac`. +1 for rc.
- wonderzombie 15y agoHonestly, I find that stuff pretty easy to remember. And is it that ugly, in the grand scheme of ugly shell syntax? :) I mean, what about [[ ]] vs. (( )) vs. [ ]? Or the beginning of a case statement? Those always get me since I don't use them often enough for them to stick.
- pyre 15y ago[ ] is easy. It's just the 'test' command.[1] % which \[ /usr/bin/[ All of the other syntax is shell-specific (run via built-ins), so that can vary, and be a little more obtuse. [1] Albiet with some minor differences: % if [ -d /tmp ]; then echo "TRUE"; fi TRUE % if test -d /tmp ]; then echo "TRUE"; fi test: too many arguments % if test -d /tmp; then echo "TRUE"; fi TRUE % diff /usr/bin/{test,\[} Binary files /usr/bin/test and /usr/bin/[ differ % man \[ No manual entry for [
- ori_b 15y agoYes. rc has less of it, fewer edge cases, etc. Even though it still has lists implemented sanely, a full set of redirects, etc: $ 9 man rc | wc -l 496 $ man bash | wc -l 4890 Fewer interactive features as well, unfortunately. But it's small enough to keep in your head, and I find that makes it far more pleasant to use.
- adavies42 15y agothe problem is there are really two things that most shells are trying to simultaneously optimize for--interactive and scripted use. sometimes these conflict in annoying ways--i think the main reason arrays are so obnoxious to use in bash is that their syntax collides badly with glob syntax. some shells that make excellent script languages are terrible for interactive use--a stock ksh, even ksh93, is pure torture for someone who grew up on bash and zsh and expects completion, history, a nice prompt, decent command editing, etc. (i'm not sure if the reverse is precisely true, though certainly there are interesting programming features in ksh that are absent in zsh--discipline functions and so on.)
- bwarp 15y agoYou've obviously never used PowerShell then if you think *sh are horrible ugly and inconsistent!