bash syntax #3

Closed
opened 2025-12-29 00:21:29 +01:00 by adam · 2 comments
Owner

Originally created by @moviuro on GitHub (Dec 5, 2015).

From a purely syntactic point of view, there are some things that can be enhanced:

  • the shebang should be #!/usr/bin/env bash so your script is portable to other UNIX systems, such as *BSD that host the bash binary at /usr/local/bin
  • you may be able to change all and any use of $* and replace it with $@ as the latter keeps arguments even if they contain spaces, whereas the former replaces "a b" to "a" "b"

I'll keep the script in my watch list and use it once when I'm ready to do some webadmin ;)

Originally created by @moviuro on GitHub (Dec 5, 2015). From a purely syntactic point of view, there are some things that can be enhanced: - the shebang should be `#!/usr/bin/env bash` so your script is portable to other UNIX systems, such as *BSD that host the `bash` binary at `/usr/local/bin` - you may be able to change all and any use of `$*` and replace it with `$@` as the latter keeps arguments even if they contain spaces, whereas the former replaces `"a b"` to `"a" "b"` I'll keep the script in my watch list and use it once when I'm ready to do some webadmin ;)
adam closed this issue 2025-12-29 00:21:29 +01:00
Author
Owner

@lukas2511 commented on GitHub (Dec 5, 2015):

At the moment i think the script isn't actually very portable. E.g.: The syntax of the base64 binary differs from system to system,
I'll change the shebang after I tested that it's actually working under (some) BSD systems.

For the $*/$@ thing thanks, I'll have a look at that.

@lukas2511 commented on GitHub (Dec 5, 2015): At the moment i think the script isn't actually very portable. E.g.: The syntax of the base64 binary differs from system to system, I'll change the shebang after I tested that it's actually working under (some) BSD systems. For the $*/$@ thing thanks, I'll have a look at that.
Author
Owner

@lukas2511 commented on GitHub (Dec 5, 2015):

I replaced the shebang with "#!/usr/bin/env bash" and the usage of ${*} versus ${@} doesn't make any difference in the places it is used, so I'll leave it as it is now.

@lukas2511 commented on GitHub (Dec 5, 2015): I replaced the shebang with "#!/usr/bin/env bash" and the usage of ${*} versus ${@} doesn't make any difference in the places it is used, so I'll leave it as it is now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/dehydrated#3