From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/3] tst_test.sh: Simplify tst_cmd_available()
Date: Wed, 18 Aug 2021 11:40:53 +0200 [thread overview]
Message-ID: <YRzVpQT1zYOvxlWe@pevik> (raw)
In-Reply-To: <7ac7a1d6-2d97-f8f5-8d60-040eb0753681@jv-coder.de>
Hi Joerg,
...
> > + type $1 >/dev/null 2>&1
> I guess there was a reason, why command was used here in the first place.
> Iirc type is often a shell builtin, that can have different behavior, while
> command -v is posix and should be extremely portable.
> So maybe it is better to use "command -v" instead of type here. I hope most
> distributions have a command-command...
Well, I wrote that code, in dba1d50cb :). IMHO both are POSIX and both are shell
builtin.
I tested it on all implementations and the only difference is that both "type"
and "command -v" on dash and busybox sh returns 127 on missing command, the rest
return 1.
Kind regards,
Petr
next prev parent reply other threads:[~2021-08-18 9:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-18 9:12 [LTP] [PATCH 0/3] shell: remove which, use type or command -v Petr Vorel
2021-08-18 9:12 ` [LTP] [PATCH 1/3] tst_test.sh: Simplify tst_cmd_available() Petr Vorel
2021-08-18 9:30 ` Joerg Vehlow
2021-08-18 9:40 ` Petr Vorel [this message]
2021-08-19 3:59 ` Li Wang
2021-08-19 6:09 ` Petr Vorel
2021-08-20 9:28 ` Petr Vorel
2021-08-18 9:12 ` [LTP] [PATCH 2/3] binfmt_misc02.sh: Use "command -v" instead of "which" Petr Vorel
2021-08-18 9:31 ` Joerg Vehlow
2021-08-18 9:42 ` Petr Vorel
2021-08-18 9:12 ` [LTP] [PATCH 3/3] commands: Drop which01.sh Petr Vorel
2021-08-18 9:32 ` Joerg Vehlow
2021-08-18 10:01 ` Petr Vorel
2021-08-19 5:49 ` Li Wang
2021-08-19 6:04 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YRzVpQT1zYOvxlWe@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox