Re: The "which -s" flag

2020-08-31 Thread Philipp Kern
On 31.08.20 22:19, Fabrice BAUZAC-STEHLY wrote:
> Simon McVittie writes:
> 
>> which(1) is non-standardized, which is likely to be part of the reason
>> why Debian has its own implementation not shared with other Linux
>> distributions. Some other Linux distributions, for example Fedora and
>> Arch Linux, use GNU Which  and
>> that doesn't seem to support the -s option either (but does support a lot
>> of other non-standard options). Adding a -s option to the debianutils
>> implementation of `which` will help your scripts to run on Debian and
>> (eventually) Debian derivatives like Ubuntu, but won't help your scripts
>> to run on Fedora or Arch.
> 
> Is there a reason why Debian doesn't use GNU Which?  Sounds like
> unnecessary maintenance to me...

Well, it looks like GNU which was last updated in 2015 (both tarball and
CVS) and despite GNU redirecting to a github.io page it doesn't look
like there is any more up-to-date repository of it either. So I'm not
sure if maintenance is a great argument here. Although I will note that
Archlinux does not actually patch it.

Kind regards
Philipp Kern



Re: The "which -s" flag

2020-08-31 Thread Fabrice BAUZAC-STEHLY
Simon McVittie writes:

> which(1) is non-standardized, which is likely to be part of the reason
> why Debian has its own implementation not shared with other Linux
> distributions. Some other Linux distributions, for example Fedora and
> Arch Linux, use GNU Which  and
> that doesn't seem to support the -s option either (but does support a lot
> of other non-standard options). Adding a -s option to the debianutils
> implementation of `which` will help your scripts to run on Debian and
> (eventually) Debian derivatives like Ubuntu, but won't help your scripts
> to run on Fedora or Arch.

Is there a reason why Debian doesn't use GNU Which?  Sounds like
unnecessary maintenance to me...

--
Fabrice BAUZAC-STEHLY
PGP 015AE9B25DCB0511D200A75DE5674DEA514C891D



Re: The "which -s" flag

2020-08-19 Thread Antonio Terceiro
On Wed, Aug 19, 2020 at 01:45:05PM +, 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.

debianutils is essential/required, and there is an infinite amount of
shell scripts and even non-shell programs that use the `which` binary
without needing a dependency on anything. Dropping it without breaking
the entire world is going to be pretty difficult to achieve, unless it
moves to another essential/required package.

That said, it could very well be reimplemented as a very small wrapper
around command -v.


signature.asc
Description: PGP signature


Re: The "which -s" flag

2020-08-19 Thread Clint Adams
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.



Re: The "which -s" flag

2020-08-18 Thread Boyuan Yang
Hi,

在 2020-08-17星期一的 20:47 +0200,Erik Gustafsson写道:
> I took Teemus very good suggestion and changed [-a] to [-as] now :)
> 
> https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs#ed04ff4dabf1e2d4cd6b89136c2b24dec27ecca4_21_24
> 
> Is there anything more I should change?
> 
> Who can merge? :)

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.

Looking at the package maintenance status at 
https://tracker.debian.org/pkg/debianutils , this package is actually curently
RC-buggy and has autopkgtest regression for several months. It would be best
if the package can be refreshed later by the maintainers; if not, we may need
to take actions before Debian 11 freeze.

Thanks,
Boyuan Yang


> Den fre 14 aug. 2020 kl 16:07 skrev Simon McVittie :
> > On Fri, 14 Aug 2020 at 14:46:39 +0200, Jonas Smedegaard wrote:
> > > Regardless of the -s option, why is command preferred over which?  Due 
> > > to it being POSIX or for some other reason?
> > 
> > * command is POSIX, so any Unixish environment should have it, whereas
> >   which is non-standard, so it's anyone's guess whether it will exist
> >   on embedded, proprietary or otherwise limited Unixes
> >   (some upstream packages don't care about this, and Debian packages never
> >   have to, but for some upstream packages it matters)
> > 
> > * relatedly, the which "API" is Unix folklore rather than formally written
> >   down, so it's easy to rely on features of one implementation that others
> >   don't have, like this -s option; debianutils which only has one option,
> >   -a, and GNU which also has that option, but it wouldn't surprise me if
> >   implementations exist that don't have -a
> > 
> > * command is a shell builtin (I don't think the spec explicitly says so,
> >   but it can't work as documented unless it is), so "command -v java"
> >   is faster and more accurately reflects what your shell will actually do
> >   when you try to run java, typically on the next line of the same script
> > 
> > smcv
> > 


signature.asc
Description: This is a digitally signed message part


Re: The "which -s" flag

2020-08-17 Thread Erik Gustafsson
I understand that if I write my own shell scripts I maybe should use
command -v instead, but this is not for my own shell scripts, but for
compatibility with BSD and Mac.



Den mån 17 aug. 2020 kl 20:47 skrev Erik Gustafsson <
ekir.gustafs...@gmail.com>:

> I took Teemus very good suggestion and changed [-a] to [-as] now :)
>
>
> https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs#ed04ff4dabf1e2d4cd6b89136c2b24dec27ecca4_21_24
>
> Is there anything more I should change?
>
> Who can merge? :)
>
> Den fre 14 aug. 2020 kl 16:07 skrev Simon McVittie :
>
>> On Fri, 14 Aug 2020 at 14:46:39 +0200, Jonas Smedegaard wrote:
>> > Regardless of the -s option, why is command preferred over which?  Due
>> > to it being POSIX or for some other reason?
>>
>> * command is POSIX, so any Unixish environment should have it, whereas
>>   which is non-standard, so it's anyone's guess whether it will exist
>>   on embedded, proprietary or otherwise limited Unixes
>>   (some upstream packages don't care about this, and Debian packages never
>>   have to, but for some upstream packages it matters)
>>
>> * relatedly, the which "API" is Unix folklore rather than formally written
>>   down, so it's easy to rely on features of one implementation that others
>>   don't have, like this -s option; debianutils which only has one option,
>>   -a, and GNU which also has that option, but it wouldn't surprise me if
>>   implementations exist that don't have -a
>>
>> * command is a shell builtin (I don't think the spec explicitly says so,
>>   but it can't work as documented unless it is), so "command -v java"
>>   is faster and more accurately reflects what your shell will actually do
>>   when you try to run java, typically on the next line of the same script
>>
>> smcv
>>
>>


Re: The "which -s" flag

2020-08-17 Thread Erik Gustafsson
I took Teemus very good suggestion and changed [-a] to [-as] now :)

https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs#ed04ff4dabf1e2d4cd6b89136c2b24dec27ecca4_21_24

Is there anything more I should change?

Who can merge? :)

Den fre 14 aug. 2020 kl 16:07 skrev Simon McVittie :

> On Fri, 14 Aug 2020 at 14:46:39 +0200, Jonas Smedegaard wrote:
> > Regardless of the -s option, why is command preferred over which?  Due
> > to it being POSIX or for some other reason?
>
> * command is POSIX, so any Unixish environment should have it, whereas
>   which is non-standard, so it's anyone's guess whether it will exist
>   on embedded, proprietary or otherwise limited Unixes
>   (some upstream packages don't care about this, and Debian packages never
>   have to, but for some upstream packages it matters)
>
> * relatedly, the which "API" is Unix folklore rather than formally written
>   down, so it's easy to rely on features of one implementation that others
>   don't have, like this -s option; debianutils which only has one option,
>   -a, and GNU which also has that option, but it wouldn't surprise me if
>   implementations exist that don't have -a
>
> * command is a shell builtin (I don't think the spec explicitly says so,
>   but it can't work as documented unless it is), so "command -v java"
>   is faster and more accurately reflects what your shell will actually do
>   when you try to run java, typically on the next line of the same script
>
> smcv
>
>


Re: The "which -s" flag

2020-08-14 Thread Simon McVittie
On Fri, 14 Aug 2020 at 14:46:39 +0200, Jonas Smedegaard wrote:
> Regardless of the -s option, why is command preferred over which?  Due 
> to it being POSIX or for some other reason?

* command is POSIX, so any Unixish environment should have it, whereas
  which is non-standard, so it's anyone's guess whether it will exist
  on embedded, proprietary or otherwise limited Unixes
  (some upstream packages don't care about this, and Debian packages never
  have to, but for some upstream packages it matters)

* relatedly, the which "API" is Unix folklore rather than formally written
  down, so it's easy to rely on features of one implementation that others
  don't have, like this -s option; debianutils which only has one option,
  -a, and GNU which also has that option, but it wouldn't surprise me if
  implementations exist that don't have -a

* command is a shell builtin (I don't think the spec explicitly says so,
  but it can't work as documented unless it is), so "command -v java"
  is faster and more accurately reflects what your shell will actually do
  when you try to run java, typically on the next line of the same script

smcv



Re: The "which -s" flag

2020-08-14 Thread Holger Levsen
On Fri, Aug 14, 2020 at 02:46:39PM +0200, Jonas Smedegaard wrote:
> Regardless of the -s option, why is command preferred over which?  Due 
> to it being POSIX or for some other reason?

developers-reference (11.0.7) unstable; urgency=medium

  * best-pkging-practices: recommend "command -v" instead of "which"
(Closes: #904246) and simplify paragraph.


https://www.debian.org/doc/manuals/developers-reference/best-pkging-practices.en.html#best-practices-for-maintainer-scripts
has the full text.

In #904246 Sean Whitton wrote:

Section 6.4 should perhaps recommend `command -v` not `which`, because
Debian Policy 4.1.5.0 allows maintainer scripts to assume SUSv4, which
requires support for `command -v`.


and further on he explained that "command" is a shell builtin for the
most common shells (including dash) while "which" is just a builtin on zsh.
so that's why.


-- 
cheers,
Holger

---
   holger@(debian|reproducible-builds|layer-acht).org
   PGP fingerprint: B8BF 5413 7B09 D35C F026 FE9D 091A B856 069A AA1C

"There's no glory in prevention." (Christian Drosten)


signature.asc
Description: PGP signature


Re: The "which -s" flag

2020-08-14 Thread Jonas Smedegaard
Quoting Simon McVittie (2020-08-14 14:29:15)
> Another angle you could attack this from is to change these scripts to 
> use "which java >/dev/null" or, better, "command -v java >/dev/null" 
> instead of "which -s java".
> 
> which(1) is non-standardized, which is likely to be part of the reason 
> why Debian has its own implementation not shared with other Linux 
> distributions. Some other Linux distributions, for example Fedora and 
> Arch Linux, use GNU Which  
> and that doesn't seem to support the -s option either (but does 
> support a lot of other non-standard options). Adding a -s option to 
> the debianutils implementation of `which` will help your scripts to 
> run on Debian and (eventually) Debian derivatives like Ubuntu, but 
> won't help your scripts to run on Fedora or Arch. Other distributions 
> might be using debianutils `which` like Debian, GNU Which like Fedora, 
> or some third implementation.
> 
> command(1) is specified by POSIX 
> (https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html) 
> and should be available on all Unix-like systems, with at least the 
> options documented in POSIX.

Regardless of the -s option, why is command preferred over which?  Due 
to it being POSIX or for some other reason?

(I tried and failed duckduckgo'ing "which command"...)


 - Jonas

-- 
 * Jonas Smedegaard - idealist & Internet-arkitekt
 * Tlf.: +45 40843136  Website: http://dr.jones.dk/

 [x] quote me freely  [ ] ask before reusing  [ ] keep private

signature.asc
Description: signature


Re: The "which -s" flag

2020-08-14 Thread Simon McVittie
On Fri, 14 Aug 2020 at 00:55:03 +0200, Erik Gustafsson wrote:
> This "which" is heavily used at the company where I work, for java
> development etc like
> which -s java || echo "You have to install java to run this program"

Another angle you could attack this from is to change these scripts to
use "which java >/dev/null" or, better, "command -v java >/dev/null"
instead of "which -s java".

which(1) is non-standardized, which is likely to be part of the reason
why Debian has its own implementation not shared with other Linux
distributions. Some other Linux distributions, for example Fedora and
Arch Linux, use GNU Which  and
that doesn't seem to support the -s option either (but does support a lot
of other non-standard options). Adding a -s option to the debianutils
implementation of `which` will help your scripts to run on Debian and
(eventually) Debian derivatives like Ubuntu, but won't help your scripts
to run on Fedora or Arch. Other distributions might be using debianutils
`which` like Debian, GNU Which like Fedora, or some third implementation.

command(1) is specified by POSIX
(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html)
and should be available on all Unix-like systems, with at least the
options documented in POSIX.

(This is not a reason to reject the addition of a -s option to which -
if users of other systems expect that option, it might as well exist -
but it might well be a quicker route to portability than patching all
the implementations of which.)

smcv



Re: The "which -s" flag

2020-08-14 Thread Nicholas D Steeves
Hi,

Teemu Likonen  writes:

> * 2020-08-14 00:55:03+02, Erik Gustafsson wrote:
>
>> To make my Debian installation compatible with "which -s" I have made a
>> merge request for this
>> https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs
>
> Reviewed-by: me, a random debian user.
>
> But perhaps you should mention the "-s" flag in the usage:
>
> ?) puts "Usage: $0 [-a] args"; exit 2 ;;
>
> Like "[-as]" maybe.
>

Agreed.  Also, the man page needs to be updated to document this change.

Cheers,
Nicholas


signature.asc
Description: PGP signature


Re: The "which -s" flag

2020-08-13 Thread Geert Stappers
On Fri, Aug 14, 2020 at 12:55:03AM +0200, Erik Gustafsson wrote:
> Hi!
> 
> The "which" command is part of debianutils. On BSD and Mac, this command on
> Mac/BSD has a -s flag, for silent, when used it does not print, just return
> 0 if program found in $PATH or 1 otherwise. See man-page for FreeBSD
> https://www.freebsd.org/cgi/man.cgi?which(1)
> 
> This "which" is heavily used at the company where I work, for java
> development etc like
> which -s java || echo "You have to install java to run this program"
> 
> We have many shellscripts using this, but unfortunately they don't
> work on GNU/Linux, only on Mac and BSD.
> 
> The current version of "which" supplied with Debian is written in
> shellscript
> https://salsa.debian.org/debian/debianutils/blob/master/which
> 
> To make my Debian installation compatible with "which -s" I have made a
> merge request for this
> https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs

Looks good to me (and also told that to Salsa)


> How to proceed to get the Merge request reviewed?

You are taking the right approach:  Just do

Now comes a challenging part: Give time to others to respond


> I have never contributed to Debian before, but I am happy to do it :)

Nice, you started

 
> Best regards,
> -Erik

 
Regards
Geert Stappers
DD


P.S.
Welcome
-- 
Silence is hard to parse


signature.asc
Description: PGP signature


Re: The "which -s" flag

2020-08-13 Thread Teemu Likonen
* 2020-08-14 00:55:03+02, Erik Gustafsson wrote:

> To make my Debian installation compatible with "which -s" I have made a
> merge request for this
> https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs

Reviewed-by: me, a random debian user.

But perhaps you should mention the "-s" flag in the usage:

?) puts "Usage: $0 [-a] args"; exit 2 ;;

Like "[-as]" maybe.

-- 
/// Teemu Likonen - .-.. http://www.iki.fi/tlikonen/
// OpenPGP: 4E1055DC84E9DFF613D78557719D69D324539450


signature.asc
Description: PGP signature


The "which -s" flag

2020-08-13 Thread Erik Gustafsson
Hi!

The "which" command is part of debianutils. On BSD and Mac, this command on
Mac/BSD has a -s flag, for silent, when used it does not print, just return
0 if program found in $PATH or 1 otherwise. See man-page for FreeBSD
https://www.freebsd.org/cgi/man.cgi?which(1)

This "which" is heavily used at the company where I work, for java
development etc like
which -s java || echo "You have to install java to run this program"

We have many shellscripts using this, but unfortunately they don't
work on GNU/Linux, only on Mac and BSD.

The current version of "which" supplied with Debian is written in
shellscript
https://salsa.debian.org/debian/debianutils/blob/master/which

To make my Debian installation compatible with "which -s" I have made a
merge request for this
https://salsa.debian.org/debian/debianutils/-/merge_requests/6/diffs

How to proceed to get the Merge request reviewed? I have never contributed
to Debian before, but I am happy to do it :)

Best regards,
-Erik