Alias expansion is not working reliably in non-interactive shells

It happened that old bash version on macOS the alias was not being expanded
for non-interactive shells running under "bash" but was being expanded fine
when under "sh". Using functions is the recommended way.

Here we define a function conditionally.

Change-Id: I607b265cb9e88b2b529ed170121e5a0833003acd
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
This commit is contained in:
Dimitrios Apostolou
2020-02-10 17:21:32 +01:00
parent c0033df4b9
commit 25fcda6ff3

View File

@@ -39,10 +39,12 @@
# based on the SHA length). Target filename should also be given.
############################ BOILERPLATE ###############################
command -v sha1sum >/dev/null || alias sha1sum='shasum -a 1'
command -v sha256sum >/dev/null || alias sha256sum='shasum -a 256'
command -v sha384sum >/dev/null || alias sha384sum='shasum -a 384'
command -v sha512sum >/dev/null || alias sha512sum='shasum -a 512'
command -v sha1sum >/dev/null || sha1sum () { shasum -a 1 "$@" ; }
command -v sha256sum >/dev/null || sha256sum () { shasum -a 256 "$@" ; }
command -v sha384sum >/dev/null || sha384sum () { shasum -a 384 "$@" ; }
command -v sha512sum >/dev/null || sha512sum () { shasum -a 512 "$@" ; }
########################################################################