Skip to content
Snippets Groups Projects

Add -s flag to which

Merged Erik Gustafsson requested to merge (removed):add-s-flag-to-which into master
1 unresolved thread

In my work place we use many shellscripts written for BSD/Mac. They often use the which -s flag to check if a command is installed, such as which -s java || echo "You have to install java to run this program"

The -s flag is described on the FreeBSD man-page https://www.freebsd.org/cgi/man.cgi?which(1)

I would like the which -s command in shellscripts written for BSD to also work in Debian. This Merge request therefor adds the -s flag to the which command, to become compatible BSD/Mac shellscripts.

Merge request reports

Checking pipeline status.

Approved by

Merged by Geert StappersGeert Stappers 3 years ago (Jun 5, 2021 7:01pm UTC)

Merge details

  • Changes merged into master with 8eaf8975.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • Geert Stappers approved this merge request

    approved this merge request

  • Highlight @clint for creating awareness of this merge request.

    The MR does not break any thing. Helps those who are used to the -s flag. And even does

    -	while getopts a whichopts
    +	while getopts as whichopts
  • Geert Stappers mentioned in commit 8eaf8975

    mentioned in commit 8eaf8975

  • The silence was recieved as no objections, so merged.

  • Geert Stappers resolved all threads

    resolved all threads

    • Text from that URL

      On Wed, Aug 19, 2020 at 01:45:05PM +0000, Clint Adams wrote:

      On Tue, Aug 18, 2020 at 10:55:41AM -0400, Boyuan Yang wrote:
      > In theory any Debian Developers may merge, but the debianutils package is
      > maintained by clint@ and srivasta@ so they are responsible for this package. I
      > am adding them to the email receiver list explicitly.
      
      Now that `command -v` is mandated by POSIX, it would make more
      sense to transition `which` out of debianutils.
      
    • Hi Clint and Geert!

      Clint: What you really cared about is not having "which" inside debianutils, and not whatever it has a -s(silent) flag or not? (I guess?)

      So merging the -s flag, should not be a problem, but what you want is to have "which" moved away from debianutils, and into another (maybe optional) package? I guess that can be done?

      Best regards -Erik

      Den lör 5 juni 2021 kl 21:30 skrev Geert Stappers (@stappers) < gitlab@salsa.debian.org>:

    • Please register or sign in to reply
  • Goal: coexist

    I think we already agree on:

    • command -v as POSIX says
    • The nice to have -s flag for which

    Thing currently unclear:

    • Which Debian package should provide the which command.
  • What I can do is, after the release of Debian 11.0, slap a deprecation warning on which at the same time I remove tempfile from the package. If a new package or multiple packages supply a /usr/bin/which executable or alternatives, with or without an -s flag, then debianutils can declare a transitional dependency and drop its own which. If not, which can be dropped immediately after the release of Debian 12.0.

  • Please register or sign in to reply
    Loading