You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several bashisms in GameShell code.
I am trying to remove some of them, more as a learning experience than as a real goal. (Even though it would make it easier to port GameShell to zsh or some other shell.)
All of this concerns primarily GameShell's code, but missions' code could also benefit from them where appropriate.
local variables do not exist in POSIX sh! The function mission_source relies on them to be re-entrant. There might be some ideas here: htps://stackoverflow.com/questions/18597697/posix-compliant-way-to-scope-variables-to-a-function-in-a-shell-script
compgen is used in save_environment.sh. This is used to compare the before / after environments when sourcing mission files. To get variables, set can be used, but I'm not sure there is a way to get a list of functions in POSIX sh
find ... -print0 and xargs -0 are not in POSIX but exist in freebsd, openbsd and macos
sleep 0.1 isn't in POSIX but is supported in freebsd, openbsd and macos
readlink -f is not in POSIX and doesn't work on macos. I wrote a small script, but it doesn't mix well when intermediate directories don't have the execute bit.
mktemp isn't in POSIX, but seems to be available in freebsd, openbsd and macos
At the moment, I only use it bare mktemp, so it would be easy to write script to do something reliable enough.
when not available, gettext and eval_gettext could be redefined using printf and eval+printf. (That would of course remove localization.)
There are several bashisms in GameShell code.
I am trying to remove some of them, more as a learning experience than as a real goal. (Even though it would make it easier to port GameShell to zsh or some other shell.)
All of this concerns primarily GameShell's code, but missions' code could also benefit from them where appropriate.
local
variables do not exist in POSIXsh
! The functionmission_source
relies on them to be re-entrant. There might be some ideas here: htps://stackoverflow.com/questions/18597697/posix-compliant-way-to-scope-variables-to-a-function-in-a-shell-scriptcompgen
is used insave_environment.sh
. This is used to compare the before / after environments when sourcing mission files. To get variables,set
can be used, but I'm not sure there is a way to get a list of functions in POSIXsh
find ... -print0
andxargs -0
are not in POSIX but exist in freebsd, openbsd and macossleep 0.1
isn't in POSIX but is supported in freebsd, openbsd and macosreadlink -f
is not in POSIX and doesn't work on macos. I wrote a small script, but it doesn't mix well when intermediate directories don't have the execute bit.mktemp
isn't in POSIX, but seems to be available in freebsd, openbsd and macosAt the moment, I only use it bare
mktemp
, so it would be easy to write script to do something reliable enough.when not available,
gettext
andeval_gettext
could be redefined usingprintf
andeval
+printf
. (That would of course remove localization.)BASHPID
is used to detect subshell, but I don't know if there is a POSIX equivalentapparently, the POSIX way of doing it is to use
sh -c 'echo $PPID'
, see https://unix.stackexchange.com/questions/484442/how-can-i-get-the-pid-of-a-subshell$RANDOM
variable : there now is aRANDOM
function (usingawk
) to do the samesource FILE
: can be replaced by. FILE
echo -n
: can mostly be replaced byprintf
read -p
: can be replaced byprintf ... ; read
read -s
: was replaced bystty -echo; read; stty echo
$'STR'
: were replacedthe variable
$OSTYPE
isn't necessary anymore since almost every problematic function has been re-implemented in a POSIX compliant wayexport -f
: it can mostly be replaced by writing an external script in$GSH_ROOT/bin
or$MISSION_DIR/bin
head -c
andtail -c
: they were replaced by instances ofdd
the command
seq
is not in POSIX! (It is not present on openbsd.) It was replaced by a small script (no option are available)The text was updated successfully, but these errors were encountered: