Quote:
I am not sure why the author of that code chose to put it inside $() but maybe a more experienced scripter around here will have some possible explanation.
|
I wouldn't say I'm a more experienced scripter, but I'll take a stab at it.
It could be a very rudimentary/poor success-check. The entire line will be replaced with the stdout/stderr of the
lame process. I don't use lame much, but I would bet it displays nothing when successful. So
if it does output something it's probably because things went wrong. So when the script replaces the pipe-sequence with the output, it's unlikely that the output will be a recognizable command for the shell to execute. So it would generate an error. For instance, a script named
simple.bash:
Code:
#!/bin/bash
for attempt in $( seq 1 3 ) ; do
$( echo "bad command");
done
exit 0
Running that script gives:
Code:
$ ./simple.bash
./simple.bash: line 4: bad: command not found
./simple.bash: line 4: bad: command not found
./simple.bash: line 4: bad: command not found
Not a very informative error.
If the lame command was successful, the output will be an empty string, making the original script execute an empty command, and continue with the loop.
All things being equal, I don't imagine the original author was trying to do anything tricky or fancy. I think the author just wasn't a bash expert and thought using $() was the only way to execute a command.