News for hackers. Stuff that matters.
Re:Bash function names can be almost anything by thunderbong on Sunday July 04, 2021 @12:56AM (#27727323)
Woah! I didn't know about the `command` trick. From the article -

  function echo { echo "$@"; }

Oops don't do that, it will recurse until the process is killed. But if you do successfully redefine a builtin command, you can call the original with command. So this is fine:

  function echo { command echo "$@"; }

Unless you also redefine the command command, then you're really screwed.
Re:Bash function names can be almost anything by mfontani on Sunday July 04, 2021 @01:46AM (#27727505)
"command" works also interactively, to call the "real" thing instead of the aliased thing.

As an example, I alias "cat" to run "bat", which pretty-prints the output. If I don't want the pretty-printed output, I can "command cat foo.txt" and it will call the "real" cat.

Re:Bash function names can be almost anything by LanternLight83 on Sunday July 04, 2021 @01:55AM (#27727535)
I like to escape aliases (ie. using `\vi` when vi is aliased to $EDITOR, but I actually want it), and actually have a special case for bat where I bind ccat to `bat -p --pager=never` for nice, copy-able, and still potentially highlighted output.
Re:Bash function names can be almost anything by stonewareslord on Sunday July 04, 2021 @02:32PM (#27731647)
You can also bypass aliases by escaping some part of the command

    ~ $ alias true='echo alias'
    ~ $ true
    alias
    ~ $ \true
    ~ $ 'true'
    ~ $ tr'u'e
    ~ $
Re:Bash function names can be almost anything by fckthisguy on Sunday July 04, 2021 @07:03AM (#27728766)
bat's great! There's an easy way to disable pretty printing too: either use the flag, or pipe to another command.
Re:Bash function names can be almost anything by ScottBurson on Sunday July 04, 2021 @06:34AM (#27728625)
Reminds me of the time I was on a Lisp Machine and did

  (trace format)
This causes a line to be printed every time FORMAT is called, showing the arguments it was called with. Well, FORMAT is Lisp's printf -- it's used everywhere, including by TRACE. Oops!!! Time for Ctrl-Meta-Ctrl-Meta-Rubout! (That was the key sequence for an immediate reboot. Interesting how it prefigured the IBM PC's Ctrl-Alt-Delete.)
Re:Bash function names can be almost anything by LeoPanthera on Sunday July 04, 2021 @02:57AM (#27727782)
Prefixing a command with a backslash is equivalent to this.

"\ls" is the same as "command ls" and will run ls ignoring any functions or aliases that normally replace it.

Re:Bash function names can be almost anything by IronBacon on Sunday July 04, 2021 @03:58AM (#27728014)
On Zsh there is also '=' as prefix, at least that's what I normally use, don't recall if it's a default setting or the result of a local configuration...
Re:Bash function names can be almost anything by JNRowe on Sunday July 04, 2021 @04:45AM (#27728176)
Perhaps you already know, but…

The `=` prefix in zsh works, but is a different beast entirely. The backslash trick will simply stop the command parser from expanding the alias, while the equals prefix will expand to the full path of the given command at parsing time. For example:

     $ print -l =cat =bat
     /usr/bin/cat
     /usr/bin/bat
While it is a trivial difference in your use case, it can be useful in itself; You could use `ldd =zsh` instead of needing to provide the full path, or `dpkg -S =make` to search for /usr/bin/make(or whatever) instead of returning results of files with the string make anywhere in the name.

It is a default setting for the expansion system(only when in zsh mode), but can be disabled with `unsetopt equals` if you dislike it. Gory details in zshexpn(1) and zshoptions(1).

Re:Bash function names can be almost anything by maddyboo on Sunday July 04, 2021 @04:50AM (#27728199)
A cool thing about = is it expands to the full path of the executable, so I often use it to edit the shell scripts that are in my PATH, e.g.

    vim =audioctl
 
Expands to

    vim /home/myusername/bin/audioctl
Re:Bash function names can be almost anything by forty on Sunday July 04, 2021 @03:37AM (#27727935)
\ls and 'ls' works for avoiding aliases, but from a quick try on termux, doesn't seem to ignore functions.
Re:Bash function names can be almost anything by mkl on Sunday July 04, 2021 @06:22AM (#27728574)
Same in bash on Linux.
Re:Bash function names can be almost anything by bombcar on Sunday July 04, 2021 @01:45AM (#27727503)
Another fun thing is many commands are built in now (like true) but ALSO exist in /bin as an entirely separate program.

And there can rarely be fun side effects.

Re:Bash function names can be almost anything by dredmorbius on Sunday July 04, 2021 @08:05AM (#27729053)
echo is in fact one of these. There's the bash shell built-in and the system executable.