yadm icon indicating copy to clipboard operation
yadm copied to clipboard

sh POSIX compliance

Open MoritzFago opened this issue 7 years ago • 8 comments

Currently you can't use yadm with a non bash shell. With Shellcheck you can check for POSIX compliance.

MoritzFago avatar Nov 06 '17 18:11 MoritzFago

This issue has been labeled as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jan 13 '22 02:01 github-actions[bot]

Hi, Im Debian maintainer of yadm package, and I have the same problem, lintian output:

N:
I: yadm: bash-term-in-posix-shell '! shopt' [usr/bin/yadm:1927]
N: 
N:   This script is marked as running under /bin/sh, but it seems to use a feature found in bash but not in the SUSv3 or POSIX shell specification.
N:   
N:   Some examples are:
N:   
N:   - == in a test, it should use = instead - read without a variable in the argument - function to define a function - source instead of . - . command args,
N:   passing arguments to commands via source is not supported - {foo,bar} instead of foo bar - [[ test ]] instead of [ test ] (requires a Korn shell) - type
N:   instead of which or command -v
N: 
N:   Visibility: info
N:   Show-Always: no
N:   Check: shell/non-posix/bash-centric
N: 
N:
I: yadm: bash-term-in-posix-shell '$(<$PROC_VERSION)' [usr/bin/yadm:1760]
N:
I: yadm: bash-term-in-posix-shell '$BASH_VERSION' [usr/bin/yadm:1455]
N:
I: yadm: bash-term-in-posix-shell ... use --no-tag-display-limit to see all (or pipe to a file/program)

angelabad avatar Apr 16 '22 10:04 angelabad

https://lintian.debian.org/sources/yadm

angelabad avatar Apr 17 '22 09:04 angelabad

@angelabad - Despite the #!/bin/sh shebang line, yadm is presently written in Bash. Any linting done, should be configured to interpret it as Bash.

The shebang line is done this way today for maximum portability between many systems which do not have a standard location for bash, but do have a standard location for sh. If /bin/sh isn't actually Bash, Bash is still executed.

There may come a time that yadm is rewritten for POSIX sh, but until then it uses many Bash specific features.

I'm not familiar with Lintian Reports, but if this is a requirement for packaging, I recommend either.

  1. Finding a way to configure the linting system to understand yadm to be using Bash
  2. or replacing the shebang line just prior to packaging with the Debian path for Bash

TheLocehiliosan avatar Apr 18 '22 14:04 TheLocehiliosan

So, we don't want to consider

#!/usr/bin/env bash

as https://en.wikipedia.org/wiki/Env says hardcoding the location as /usr/bin/env "suffers from the same problem in that the path to the env binary may also be different on a per-machine basis" ?

Is env in a non-standard location common? I see #!/usr/bin/env bash used almost everywhere.

rasa avatar Apr 18 '22 15:04 rasa

I have found /bin/sh to be ubiquitous, where /usr/bin/env is not.

You can see some of the history here:

https://github.com/TheLocehiliosan/yadm/issues/14

TheLocehiliosan avatar Apr 19 '22 02:04 TheLocehiliosan

@TheLocehiliosan Gotcha, thx. I never got yadm to work under Busybox, but have successfully used it under iSH.

rasa avatar Apr 19 '22 05:04 rasa

Hi @TheLocehiliosan, on Debian I solved the problem patching shebang, but I think yamd could get errors on others systems, like alpine linux, *BSD, etc.. These systems don't have sh compatible with bash.

angelabad avatar Apr 21 '22 09:04 angelabad