TheLocehiliosan / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
5.06k stars 176 forks source link

sh POSIX compliance #94

Open MoritzFago opened 6 years ago

MoritzFago commented 6 years ago

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

github-actions[bot] commented 2 years ago

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.

angelabad commented 2 years ago

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 commented 2 years ago

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

TheLocehiliosan commented 2 years ago

@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
rasa commented 2 years ago

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.

TheLocehiliosan commented 2 years ago

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

rasa commented 2 years ago

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

angelabad commented 2 years ago

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.