[HN Gopher] asdf banned_commands
___________________________________________________________________
asdf banned_commands
Author : tosh
Score : 53 points
Date : 2022-10-29 13:47 UTC (9 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| js2 wrote:
| If you were as confused as I was where "run" is defined and how
| "output" gets set, and what the heck the bats extension is:
|
| (1) https://github.com/bats-core/bats-
| core/blob/ca5a2dce94/lib/b...
|
| (2) https://github.com/bats-core/bats-
| core/blob/ca5a2dce94/lib/b...
|
| (3) bash automatic testing system.
| Game_Ender wrote:
| It's interesting they banned the "echo" command but then use it
| in the tests [0].
|
| 0 - https://github.com/asdf-
| vm/asdf/blob/master/test/banned_comm...
| qbasic_forever wrote:
| Banned is a bad term, these commands are non-portable or
| unpredictable and therefore not allowed in asdf scripts. Tests
| are totally different and might be constrained to run on
| specific platforms where you can and should use all the
| platform features to better run tests.
| rbongers wrote:
| Check out also shellcheck. It's been an invaluable tool keeping
| my scripts portable.
| ryan-duve wrote:
| Are these meant to be programmatically enforced via CI? If so, I
| wonder if adding an Alpine-based build to the pipeline would
| cover all the unsupported commands automatically.
| MetricMike wrote:
| That'd be a great addition!
|
| Historically, the list of architectures that public github
| action runners make available has been quite limited. Having an
| alpine runner to surface unsupported commands would be a huge
| win.
|
| That being said, it's very useful as a plugin dev to have this
| test suite while working on a WSL2/Ubuntu so that I don't need
| to run a full CI build every time
| nequo wrote:
| This is a valuable effort for portability. I had no idea `source`
| was not POSIX compliant but `.` was, or what flags `grep` doesn't
| support on macOS.
|
| But it is ironic that the script uses `echo` to show a message
| that `printf` is preferred to `echo`. I guess what is meant is
| that `printf` is preferred to `echo -[en]`.
| remram wrote:
| echo is fine when its argument is not a variable.
| hvdijk wrote:
| The script does echo variables: echo
| "banned command $cmd: $output"
|
| This is non-portable if there is any possibility that these
| variables contain backslashes.
| TechBro8615 wrote:
| The script is for static analysis, so it only needs to run
| once against each code change, and in theory it shouldn't
| need to be portable code, unless the code under test is the
| static analysis code itself.
|
| In other words, they control where this script runs and
| there is no need to run it on more than one platform, so
| it's okay for it to be non-portable.
| nequo wrote:
| TIL: dash$ x="foo\nasd" dash$ echo
| "$x" foo asd dash$ printf "%s\n" "$x"
| foo\nasd dash$ zsh% x="foo\nasd"
| zsh% echo "$x" foo asd zsh% printf "%s\n"
| "$x" foo\nasd zsh% bash$
| x="foo\nasd" bash$ echo "$x" foo\nasd
| bash$ printf "%s\n" "$x" foo\nasd bash$
| norvvryo wrote:
| Enlightening
|
| From POSIX:
|
| >echo - write arguments to standard output
|
| >If the first operand is -n, or if any of the operands
| contain a <backslash> character, the results are
| implementation-defined.
| fragmede wrote:
| bash$ echo -e $x foo asd bash$
| heynowheynow wrote:
| sed, grep, and find are radically different on macOS (4.4BSD +
| early FreeBSD + many hacks since).
| heynowheynow wrote:
| Where does asdf hide bats? I don't see the source of it. Austin
| maybe?
___________________________________________________________________
(page generated 2022-10-29 23:01 UTC)