News for hackers. Stuff that matters.
Re:What Shell Am I Using? by jan6 on Monday August 31, 2020 @02:10AM (#24328903)
which "$(echo $0)" should work no matter the invokation ;p if full path, it still returns full path, if just "bash" or such it finds it from $PATH, badoom!
Re:What Shell Am I Using? by xorcist on Monday August 31, 2020 @02:56AM (#24329101)
The only reason anyone would want to say "$($echo $0)", echoing the variable through a subshell and substituting it with itself, is to rely on the subshell parameter splitting to remove duplicate field separators from the variable.

That is likely not the case there, and any such file names are unlikely to exist. Just say: which "$0"

Re:What Shell Am I Using? by aidenn0 on Monday August 31, 2020 @02:45AM (#24329051)
Which is not guaranteed to be present. 'command -v' should work on any posix shell though.
Re:What Shell Am I Using? by em500 on Monday August 31, 2020 @03:01AM (#24329120)
As the author notes in the 2nd section, that will return the location of the shell binary in the user path, which is not necessarily the one that is currently running.
Re:What Shell Am I Using? by contingencies on Monday August 31, 2020 @04:29AM (#24329470)
Nah.

  $ which "$(echo $0)"
  which: illegal option -- b
  usage: which [-as] program ...

  $ echo $0
  -bash
OSX. True story.
Re:What Shell Am I Using? by SAI_Peregrinus on Monday August 31, 2020 @02:43PM (#24334620)
Only for POSIX shells.

fish: $(...) is not supported. In fish, please use '(echo)'. which "$(echo $0)" ^

;)

Re:What Shell Am I Using? by 0x0 on Monday August 31, 2020 @02:47AM (#24329065)
But you might have customized your PATH after your shell was executed? So this does not seem accurate.