-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use command -v
instead which
command
#3154
base: main
Are you sure you want to change the base?
Conversation
Hi @kloczek. Thanks for your PR. I'm waiting for a ostreedev member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Minimize build requirement. Use standard POSIX sh `command -v` instead separated external which command. Fixes ostreedev#2825 Signed-off-by: Tomasz Kłoczko <[email protected]>
This is one of those PRs that you click into and expect it's gonna be an easy review and merge... And then it's not... Maybe we can do some kind of an or, use which or command -v ? I also notice in one of these files the shell isn't specified in the top line |
DESCRIPTION
The command utility shall cause the shell to treat the arguments as a simple command, suppressing the shell function lookup that is described in [Command Search and Execution](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01), item 1b.
If the command_name is the same as the name of one of the special built-in utilities, the special properties in the enumerated list at the beginning of [Special Built-In Utilities](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_14) shall not occur. In every other respect, if command_name is not the name of a function, the effect of command (with no options) shall be the same as omitting command.
When the -v or -V option is used, the command utility shall provide information concerning how a command name is interpreted by the shell.
OPTIONS
The command utility shall conform to XBD [Utility Syntax Guidelines](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html#tag_12_02).
The following options shall be supported:
-p
Perform the command search using a default value for PATH that is guaranteed to find all of the standard utilities.
-v
Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see [Shell Execution Environment](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_12)), to invoke command_name, but do not invoke command_name.
Utilities, regular built-in utilities, command_names including a <slash> character, and any implementation-defined functions that are found using the PATH variable (as described in [Command Search and Execution](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01_01)), shall be written as absolute pathnames.
Shell functions, special built-in utilities, regular built-in utilities not associated with a PATH search, and shell reserved words shall be written as just their names.
An alias shall be written as a command line that represents its alias definition.
Otherwise, no output shall be written and the exit status shall reflect that the name was not found. |
I hear ya, I'm just wondering why the builds are failing, does this work on all the builds? |
Probably because |
Hmm .. but his PR is not changing anything around use |
We iterate over |
Good spot @jlebon ! Changing:
to
should work. Although leaving which as a build dependency would be fine... |
We could just leave |
He meant change:
to
which would likely fix this just fine. |
In above there is nothing bash specific. |
I think if you take preference it's fine as long as it's reasonably portable. /bin/bash is a build dependency though, it's in the shebang line of these scripts. |
There's certainly no harm in this, but I'm fairly positive that the tests require |
Oh, but it does appear that bash is used basically everywhere. The problem is that |
In this case, I think the better fix is not to use |
Hi! 👋 @kloczek there are further uses of ostree/src/boot/grub2/grub2-15_ostree Line 20 in 695a52a
The above in particular is problematic, as it breaks on enduser systems if Adapting the following would rid this project of Lines 9 to 19 in 695a52a
Line 33 in 695a52a
Line 20 in 695a52a
|
[..] Bash is generally compatible with POSIX sh (+/- how it is handled loops body which in case of |
Yes, that's why I wrote "adapted". While it would be great to remove So if you could adjust the grub related occurrence in this PR as well, that would be ace! :)
|
If we just use I'm not sure it's worth delving too deeply into POSIX, bash is a dependency and we only support one Unix-like platform, Linux. |
|
I don't think POSIX compliance is a goal of ostree tbh, bash is a dependency, type -P is part of bash |
What is the gal of ostree may be orthogonal to targets of the distributions using ostree. |
I'm not sure if bash is used in any performance-critical runtime path on ostree, as a build/test time dependency it should be ok on most platforms. Installing extra dependancies for build time is normally ok. That said if there are one or two places bash is used during actual runtime in final deliverable packages I would be a fan of rewriting those shell scripts from the perspective of being friendly to distributions that don't distribute GPLv3 code, maybe it would make sense to be POSIX compatible, multi-shell compatible, portable in these cases, where they exist. But these are tests. I think you could write these tests to be POSIX friendly if you wanted to, but this PR doesn't work, it's failing the build. |
The difference in performance among various |
This PR is ONLY about NUMBER of build dependencies. |
This project uses bash in several places and expects to use the features of bash. That's why all of those scripts start with |
Agree with Dan above. So no objections to merging from me, but the test suite has to work, and this currently breaks it:
It seems there's not an option to get the full path; what this test is doing is inherently kind of hacky of course... |
/ok-to-test |
Yes, but if you really want to trim that, you should be trying to set |
Minimize build requirement.
Use standard POSIX sh
command -v
instead separader external which comman. Fixes #2825