Fun fact: you can define a shell function which uses a subshell like so:

my_func() (

No need for { ( ) }


Fun fact v2: any statement can be the body of a shell function

foobar() case "$1" in
echo hi

@sir that's a really fun fact I will keep it in my fact book

@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:

Sign in to participate in the conversation
Mastodon is a private Mastodon instance for friends of SirCmpwn.