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

fix(utimes): change /dev/stdin to - #1124

Merged
merged 1 commit into from
Dec 15, 2023
Merged

fix(utimes): change /dev/stdin to - #1124

merged 1 commit into from
Dec 15, 2023

Conversation

rasa
Copy link
Contributor

@rasa rasa commented Dec 13, 2023

As not all environments have /dev/stdin. See ish-app/ish#944

Sorry ‘bout that.

As not all environments have /dev/stdin. See ish-app/ish#944
@spacewander
Copy link
Collaborator

As not all environments have /dev/stdin. See ish-app/ish#944

Sorry ‘bout that.

Thanks for your contribution.
No need to be sorry about this!

Copy link
Collaborator

@hyperupcall hyperupcall left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution - I'll approve these changes, but I'm not certain they are necessary? According to the manpage:

Bash handles several filenames specially when they are used in redirec‐tions, as described in the following table. If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally with the behavior described below.

/dev/stdin: File descriptor 0 is duplicated

Since our shebang points to Bash, I think this shouldn't be a problem. :)

@rasa
Copy link
Contributor Author

rasa commented Dec 14, 2023

Since our shebang points to Bash, I think this shouldn't be a problem. :)

@hyperupcall It’s not a bash thing, the device doesn’t exist in the OS:

iPad:~# echo whoami | bash -
root
iPad:~# echo whoami | bash /dev/stdin
bash: /dev/stdin: No such file or directory
iPad:~# uname -a
Linux iPad 4.20.69-ish SUPER AWESOME May 20 2023 23:41:32 i686 Linux

Note that since iSH (and CloudLinux) don’t support /dev based file descriptors, other common bashisms, such as process substitution, fail too:


iPad:~# cat < <(ls -1 /dev)
bash: /dev/fd/63: No such file or directory
iPad:~# cat <<<$(ls -1 /dev)
clipboard
console
full
location
null
ptmx
pts
random
tty
tty1
tty2
tty3
tty4
tty5
tty6
tty7
urandom
zero

See ish-app/ish#164

@hyperupcall
Copy link
Collaborator

hyperupcall commented Dec 14, 2023

@rasa I don't quite understand - your example code is not running under Bash. I don't expect echo whoami | bash /dev/stdin to work, but I expect bash -c "echo whoami | bash /dev/stdin" to work. The shebang of git-utimes points to bash, not sh. The manpage says that if the device does not exist on the OS, bash will "emulate it"?

@rasa
Copy link
Contributor Author

rasa commented Dec 15, 2023

your example code is not running under Bash.

It is, as cat < <(ls -1 /dev) is a bashism, that doesn't work in sh/ash/dash.

@hyperupcall
Copy link
Collaborator

I see - perhaps I misread the Bash man page as those /dev/stdin files are not being used for redirection. The bash: /dev/fd/63: No such file or directory error does seems to suggest that this is being ran under Bash.

Thanks for the fix

@hyperupcall hyperupcall merged commit cdbcef3 into tj:main Dec 15, 2023
@rasa rasa deleted the patch-3 branch January 21, 2024 16:16
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