Fun fact v2: any statement can be the body of a shell function
foobar() case "$1" in
@sir does a pipeline count as a statement?
foobar() ls -l |grep head
@Wolf480pl no. That's considered a command-list (in grammar terms), and the function takes a compound-command. There's an explicit list of compound-commands here:
You can, however, perma-redirect a function to a file or file handle, so this works:
foobar() ls -l >example
The following redirections are valid here:
cmpwn.com is a private Mastodon instance for friends of SirCmpwn.