Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Note, while you should feel free to use any interactive shell you like, you should only write scripts with POSIX sh. A friend of mine is working on another shell, mrsh, which aims to be POSIX-sh-as-a-library and will serve as the basis for building more sophisticated interactive shells on a POSIX base, if anyone is interested in that:

https://git.sr.ht/~emersion/mrsh



I have a better idea: don't write scripts in shell language at all. They're terrible at basically everything. Instead, use a scripting language, like Python, Ruby, or Perl. They have control flow that make sense, are not riddled with subtle bugs due to legacy and compatibility reasons, and are simply easier to wield.

Shell scripts are a maintenance nightmare - even when used for personal scripts. They should be avoided at all cost.


Ruby and Python are pretty unwieldy for the kind of situations that are well-suited to shell scripts. It's a pain to spawn a command, a pain to make sure you get the process's output in the right place, and just far more overhead than necessary.

I agree, however, that classic shells are worse, because they lack many of the niceties expected in modern languages and have opaque, sensitive syntax.

fish shell has made me pretty happy. It's a great middle ground. It makes no pretense at POSIX compatibility. Truly a shell for the 90s.


Agreed.

There's definitely a good demand for a modern shell scripting language but fish is an existing solution that is saner than bash/zsh.

I don't use fish as a shell but for shell scripts only as it acted a bit weird on me, though it's possible I didn't search enough but zsh can cover pretty much all I want from fish with plugins.


rc from plan 9 is simple but quite powerful and has very clean syntax. It also does away with the cruft in bourn. http://www.scs.stanford.edu/nyu/04fa/sched/readings/rc.pdf

There is a port of a few very useful plan 9 tools, including rc and the Acme editor, in https://9fans.github.io/plan9port/

https://en.wikipedia.org/wiki/Plan_9_from_User_Space


shell is incredibly powerful when you interact with tools that use piping. Doing the same in python is much more verbose.


Nonsense, shell scripts are an incredibly useful tool for a huge variety of use-cases. Shell can be learned like anything else, and it mostly makes sense when it does. More so than I can say for Ruby and Perl, that's for sure!

You should know when to stop and reach for a different tool, but that point isn't before you use shell scripts at all.


While that's true for portability (there's obviously reasons why nearly all distros ship with a POSIX sh compatible shell at /bin/sh), for simple tasks on my own system, oftentimes I simply want to get the job done without banging my head against a wall dealing with all the idiosyncrasies of sh. For internal use, I think this project excels for automation and administration tasks. Of course, I probably wouldn't ship anything written in xonsh-python, but I'd totally use it to, say, back up my dotfiles to a git repo automatically.


Because many distros ship with /bin/sh linked as bash, I think using arbitrary shells for your personal scripts encourages bad habits that can easily lead to mistakenly writing non-portable scripts elsewhere without realizing it. This has happened to me many times!

POSIX shell is not really worse than bash or any of the other choices imo. For tasks to which it's not suited, bash et al probably isn't either, and you should just use Python.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: