re: Shellscripting VIEW POST

VIEW FULL DISCUSSION
 

Addendum: It's best practice to write POSIX-compliant shell scripts. Never assume that your users have your shell.

#! /bin/sh

That's all you should need for shell scripts.

 

Yeah, I would agree that setting zsh as default shell would be a bad idea, it's here just for example purposes.

On the other hand, I've already encountered an issue when I've set shebang to be /bin/sh and after googling for a while I've found that preferred shell for scripts should be bash as basically bash is sh, but with more features and better syntax.
So, I would say that:

#!/usr/bin/env bash

is maybe a better solution.

source

 

Unless your audience doesn't have bash...

Do you really need the additional features for your scripts?

Well, if you put it that way :D I guess you're right. Nevertheless, I don't think that I will write scripts for other users than me anytime soon.

code of conduct - report abuse