tj / git-extras

GIT utilities -- repo summary, repl, changelog population, author commit percentages and more
MIT License
17.3k stars 1.21k forks source link

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

Closed rasa closed 9 months ago

rasa commented 9 months ago

As not all environments have /dev/stdin. See https://github.com/ish-app/ish/issues/944

Sorry ‘bout that.

spacewander commented 9 months ago

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!

rasa commented 9 months ago

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 https://github.com/ish-app/ish/issues/164

hyperupcall commented 9 months ago

@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 commented 9 months ago

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 commented 9 months ago

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