Skip to content
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

test: The test were leaving '2' files behind #1247

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

hfiguiere
Copy link
Collaborator

The syntax to output to stderr was incorrect

The syntax to output to stderr was incorrect
@GeorgesStavracas
Copy link
Member

Hm. My bash redirection knowledge is quite limited, but according to this documentation page, redirecting stdout to stderr is documented as 1>&2. This branch changes it to >&2, without the 1.

Is this bashism? If yes, is it a harmless bashism, or something to avoid? Is 1 always the default?

@hfiguiere
Copy link
Collaborator Author

It was doing &>2 which redirect into 2 (a file name). >&2 mean stdout to stderr (the stdout is implicit).

@GeorgesStavracas GeorgesStavracas added this pull request to the merge queue Dec 26, 2023
Merged via the queue into flatpak:main with commit aa4aeeb Dec 26, 2023
4 checks passed
@hfiguiere hfiguiere deleted the test-fix branch December 26, 2023 15:44
@smcv
Copy link
Collaborator

smcv commented Jan 2, 2024

FYI:

>&2 or equivalently 1>&2 is standardized POSIX sh syntax for "make fd 1 (stdout) into a duplicate of fd 2 (stderr)". The 1 does not need to be given explicitly, because > or >> defaults to acting on fd 1 unless otherwise stated.

&>2 is a bashism (i.e. documented by bash, but with no specified meaning in arbitrary POSIX shells). In bash, it means send both stdout and stderr to a file named 2. The POSIX equivalent of &>foo is >foo 2>&1, or equivalently and more explicitly 1>foo 2>&1.

Confusingly, bash also allows writing >foo 2>&1 as >&foo, but only if the filename foo is neither a number nor -, each of which means something different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug tests Test suite
Projects
No open projects
Status: Triaged
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants