-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
fix basename: illegal option -- b issue with upstream filenames starting with - #17143
Conversation
sorry for the re-submit pr for confuse. but it do a wrong swap for my repo master branch, it let original pr is removed. so i have to re-pr the patch. |
Can you please paste your full path so we can determine what part of the thing is being interpreted as a flag. I cannot reproduce this locally unless I create a filename that starts with a |
i am follow CONTRIBUTING.adoc +140 line
it raised error above in desc. |
Could you please paste your full path? |
in my gopath:
|
Please, your FULL path -- what is |
|
@xiaods could you please run:
|
sorry for late response. @stevekuznetsov
|
@xiaods can you also please print? $ echo $( echo $0 ) The logic in Lines 53 to 55 in 1ed4596
|
it output
|
That's very interesting. Could you change this patch to instead detect when |
hack/lib/init.sh
Outdated
@@ -51,7 +51,7 @@ os::log::stacktrace::install | |||
os::util::environment::update_path_var | |||
|
|||
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then | |||
os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )" | |||
os::util::environment::setup_tmpdir_vars "$( basename -- "$0" ".sh" )" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should do:
if [[ "$0" ~= *.sh ]]; then
os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )"
else
os::util::environment::setup_tmpdir_vars "shell"
fi
The intent here was not to create a dir for the name of your shell
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update done.
also report error:
|
You'll want to trace the error -- I would not expect $ [[ "-bash" == *.sh ]] && echo matches
$ [[ "ba.sh" == *.sh ]] && echo matches
matches |
@stevekuznetsov finally fix it. please have a look the patch |
hack/lib/init.sh
Outdated
@@ -50,8 +50,10 @@ os::log::stacktrace::install | |||
# them before every invocation. | |||
os::util::environment::update_path_var | |||
|
|||
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want this condition as the top-level if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix it.
hack/lib/init.sh
Outdated
@@ -50,8 +50,10 @@ os::log::stacktrace::install | |||
# them before every invocation. | |||
os::util::environment::update_path_var | |||
|
|||
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then | |||
os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )" | |||
if [[ -z "${OS_TMP_ENV_SET-}" ]] && [[ "$0" =~ *.sh ]]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I think in this case we are still not having the same logic -- would want:
if [[ -z "${OS_TMP_ENV_SET-}" ]]; then
if [[ "$0" =~ *.sh ]]; then
os::util::environment::setup_tmpdir_vars "$( basename "$0" ".sh" )"
else
os::util::environment::setup_tmpdir_vars "shell"
fi
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @stevekuznetsov , i have been done.
…ing with - issue: ``` xiaods at XiaoTommydeMacBook-Pro in ~/go/src/github.com/openshift/origin on devel* $ export PATH="${PATH}:$( source hack/lib/init.sh; echo "${OS_OUTPUT_BINPATH}/$( os::build::host_platform )/" )" basename: illegal option -- b usage: basename string [suffix] basename [-a] [-s suffix] string [...] ``` caused by : The -- (dash dash) stops basename from processing any options in the argument. Always quote $0 in case there are spaces in the name.
/ok-to-test Thanks @xiaods |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: stevekuznetsov, xiaods The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test all [submit-queue is verifying that this PR is safe to merge] |
@xiaods: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 17476, 17143, 15115, 17094, 17500). |
issue:
caused by :
The -- (dash dash) stops basename from processing any options in the argument.
Always quote $0 in case there are spaces in the name.