[riot-notifications] [RIOT-OS/RIOT] Remove `which` from shell invocations (#16776)

chrysn notifications at github.com
Tue Aug 24 15:43:32 CEST 2021


### Contribution description

The `which` command is being deprecated in Debian (see references below).

This moves all invocations in the build system from `which` to the successor `command -c`.

### Testing procedure

Try building anything on a recent Debian sid system. While it'll fail on master, after #16775 you'll get several lines of

```
/usr/bin/which: this version of `which' is deprecated; use `command -v' in scripts instead.
```

that are gone after this patch sequence.

Any attempt to reintroduce `$(shell which ...)` in the Makefiles should also trigger the sanity checks of dist/tools/buildsystem_sanity_check/check.sh.

### Issues/PRs references

This is a follow-up of (and based on) #16775. It was split out after [some build process](https://github.com/RIOT-OS/RIOT/runs/3411537020?check_suite_focus=true) spew errors for not knowing `command`. As #16775 is blocking my workflows and I'd have to keep it around on each of my branches, I'd like to make that mergable quickly, and keep this for discussions of whether all of our users are now on platforms where command is available. (It has already been in use in some places in the build system, but these seem not to have been covered in that particular build platform).

debianutils' which, in its [changelog](https://salsa.debian.org/debian/debianutils/-/blob/master/debian/NEWS), states:

```
  * The 'which' utility will be removed in the future.  Shell scripts
    often use it to check whether a command is available.  A more
    standard way to do this is with 'command -v'; for example:
      if command -v update-icon-caches >/dev/null; then
        update-icon-caches /usr/share/icons/...
      fi
    '2>/dev/null' is unnecessary when using 'command': POSIX says "no
    output shall be written" if the command isn't found.  It's also
    unnecessary for the debianutils version of 'which', and hides the
    deprecation warning.
```

Note that this PR does *not* change which to command, it just fixes the fallout of ill-sequenced redirects. That change is probably good to do, but right now this should be minimal enough to get merged quickly, and I don't want it held up in the question of whether everyone and their dog already implement POSIX `command`.
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/16776

-- Commit Summary --

  * makefiles: Sort >/dev/null and 2>&1
  * makefiles: Replace `which` with `command -v`
  * makefiles: Reject `shell which` in new code

-- File Changes --

    M .github/workflows/release-test.yml (2)
    M Makefile.include (18)
    M dist/tools/buildsystem_sanity_check/check.sh (12)
    M dist/tools/openvisualizer/makefile.openvisualizer.inc.mk (6)
    M makefiles/arch/riscv.inc.mk (2)
    M makefiles/boards/sam0.inc.mk (2)
    M makefiles/tools/gdb.inc.mk (2)
    M makefiles/tools/riotgen.inc.mk (2)
    M pkg/flatbuffers/Makefile.include (2)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/16776.patch
https://github.com/RIOT-OS/RIOT/pull/16776.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16776
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210824/57cec2d0/attachment.htm>


More information about the notifications mailing list