The goal is to create a one line (copy and paste) bash command. The bash one line command should partition and format a drive, and when that results in a mountable volume, some initial maintenance commands.
The goal is to execute a list of commands when cd /Volumes/VolumeName succeeds in the current shell context. This grouping of commands can be done in bash by using curly braces. When cd /Volumes/VolumeName fails (echo $? != 0) further command execution is not necessary and command execution can stop.
The result of command cd /Volumes/$VOL && {sudo rm -fr .{,_.}{fseventsd,Spotlight-V100,Trashes}; mkdir .fseventsd;} is:
-bash: syntax error near unexpected token `}'
The bottleneck might be that one of the commands in the curly braced command list is using curly braces for list generation: sudo rm -fr .{,_.}{fseventsd,Spotlight-V100,Trashes}.
How to nest curly braces for list generation inside a curly brace command group?
You’re just missing a necessary leading space. Consider:
If you look in
man 1 bashunder the Compound Commands section you’ll see this (emphasis mine):