Skip to content

[infra] Discard output from the cd command when followed by pwd#16244

Merged
hseok-oh merged 1 commit into
Samsung:masterfrom
arkq:bash-cd-fix-infra
Nov 4, 2025
Merged

[infra] Discard output from the cd command when followed by pwd#16244
hseok-oh merged 1 commit into
Samsung:masterfrom
arkq:bash-cd-fix-infra

Conversation

@arkq

@arkq arkq commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

This commits fixes the issue when cd is followed by the pwd in a bash one-liner which should get the directory in which the executed script is located. The problem with such approach is that the cd command can print the destination directory in case when one has the CDPATH environmental variable set.

From the man bash:

cd [-L|...] [dir]
Change the current directory to dir. [...] If a non-empty directory
name from CDPATH is used the absolute pathname of the new working
directory is written to the standard output.

This PR is part of draft #16238

Testing

Verified locally that now, on the host with CDPATH set, it is possible to list and run commands when outside repo dir:

$ ONE/nnas
Usage: ONE/nnas [COMMAND] ...
Command:
  copyright-check
  ...
  verify-package
$ ONE/nncc configure
-- The C compiler identification is GNU 13.3.0
  ...
$ ONE/nnfw configure
-- Building for x86-64 Linux
  ...

ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy a.bokowy@samsung.com

hseok-oh
hseok-oh previously approved these changes Oct 27, 2025

@hseok-oh hseok-oh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread nnas
Comment thread nnas
Comment thread nnas
Comment thread nncc
Comment thread nncc
Comment thread nncc
Comment thread nnfw
Comment thread nnfw
Comment thread nnfw
This commits fixes the issue when `cd` is followed by the `pwd` in a
bash one-liner which should get the directory in which the executed
script is located. The problem with such approach is that the `cd`
command can print the destination directory in case when one has the
CDPATH environmental variable set.

From the `man bash`:

> cd [-L|...] [dir]
>   Change the current directory to dir. [...] If a non-empty directory
>   name from CDPATH is used the absolute pathname of the new working
>   directory is written to the standard output.

ONE-DCO-1.0-Signed-off-by: Arkadiusz Bokowy <a.bokowy@samsung.com>
@arkq

arkq commented Nov 2, 2025

Copy link
Copy Markdown
Contributor Author

@seanshpark all comments have been addressed, please re-review :)

@hseok-oh hseok-oh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hseok-oh hseok-oh merged commit a054e34 into Samsung:master Nov 4, 2025
14 checks passed
@arkq arkq deleted the bash-cd-fix-infra branch November 4, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants