4 ms·
That's probably because most people only sporadically have to write shellscripts. If you had to write it every day, I bet you wouldn't have that problem. Havin
by stingraycharles 17y ago
That's probably because most people only sporadically have to write shellscripts. If you had to write it every day, I bet you wouldn't have that problem.
Having said that, I personally don't feel shellscripting is all that intuitive either.
- scott_s 17y agoAs soon as my shellscripts need control structures, I jump to a "real" language like Perl or Python.
- ash 17y agoHaven't used it much, but I find Fish shell control structures much more consistent that those in *sh: http://fishshell.org/ http://fishshell.org/
- wheels 17y agoIndeed -- that's where Perl still fits into my day-to-day toolbox. It's exactly in those 5-50-liners with a little logic that I want a language with an overabundance of syntactic shortcuts. Shell is the exact opposite of that.
- cabalamat 17y ago> That's probably because most people only sporadically have to write shellscripts. Does anyone have to write shellscripts? If I'm writing one and it has any degree of complexity at all -- i.e. has loops or subroutines -- I just write it in Python. The only part of bash I know is the subset I use interactively on the command line.
- andrewvc 17y agoAgreed. The only reason I've had to learn any 'real' shell is to write portable init scripts. That being said, I'd probably rather write init scripts in ruby or python anyway. Besides, init scripts aren't really portable (across distros) to start with, ubuntu/debian scripts rely on start-stop-daemon and a specific filesystem layout. The use of shell for init scripts is probably only useful because using dash (/bin/sh) to execute them is likely faster than using a fancier language (though I haven't benchmarked this). BTW, ever try and write anything non-trivial using dash (POSIX shell features only). It's pretty painful. Lots of people mistakenly write shell using non-posix (bash) features, and are unpleasantly surprised when /bin/sh links to dash, thus breaking their scripts.
- nailer 17y agoI've written large scripts in bash (using range ellipses, arrays, /dev/tcp, arithmetic shells, nested subshells, IFS changing & $@ to handle filenames with spaces, etc) as part of writing kickstart scripts, RPM install / update scripts, and initscripts. I'm also familiar with object pipelining shells from using powershell. ANI looks like an unreadable mess to me.