[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#818687: RFS: btrfs-progs/4.4.1-1.1 [NMU]



* Nicholas D Steeves <nsteeves@gmail.com>, 2016-04-20, 19:41:
"if [ -x /usr/sbin/update-initramfs ] && [ -e /etc/initramfs-tools/initramfs.conf ]"

I don't think there's anything particularly wrong with that line.

The previous attempts at fixing this (using 'hash' and 'command -v') are both bashisms so they shouldn't be used.

If you really want to fix the lintian warning, using 'which' is probably the best idea here since it's an essential executable, not a shell builtin.

if which update-initramfs > /dev/null 2>&1 && [ -e /etc/initramfs-tools/initramfs.conf ]

My first instinct was to use `which command`, which is what I generally use, but because this was official Debian work I read up on which vs hash vs command -v. What I found was that `which` has undefined exit values from xNIX to yNIX, and is apparently considered bad style by some people. Hash was the oldest posix-correct way to do it, using a shell internal function.

Policy §10.4 says that /bin/sh script need to follow SUSv3 + some extensions. Both "hash" and "command -v" are optional in SUSv3 (but they are mandatory in SUSv4), so in theory you shouldn't use them. In practice, however, "command -v" is probably more portable than anything else.

"which" is not standardized, but you can rely on it as far as Debian in concerned, because it's shipped by an essential package.

Related bugs: #747320, #733511

In this case, I think it broke on piuparts because piuparts used bash; so I think this was an dashism rather than a bashism ;-)

You can't rely on the output format of argumentless "hash"; but other than that it works fine in both dash and bash.

--
Jakub Wilk


Reply to: