pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Understanding this code
tgruhn2%gmail.com@localhost (Todd Gruhn) writes:
>exec gm convert $1 -coalesce +adjoin $(pwd)/$2/frame-%d.png
>I now understand 'gm convert' but the rest of this line
>makes any sense. And it does not work
For the rest of the line you need to understand what a shell
does and what parameters the 'gm convert' command accepts.
The line is apparently taken from a shell script and is not
meant to run out of context.
exec means that the gm command is replacing the shell, it's
the last command executed. The script only continues if
the gm command couldn't be executed at all (e.g. it's not
found in the PATH).
gm convert selects the format conversion functionality of gm.
$1 is the first parameter passed to the shell script, it's
passed to 'gm convert' as the input file to read. Since
it's not quoted, it may also be a whitespace separated
list of input files.
-coalesce flattens the input data, i.e. something like
an animation or movie is split into individual frames.
+adjoin causes output to be written as individual frames
instead of a single file.
$(pwd) runs the pwd command to determine the path to the
current directory.
$2 is the second parameter passed to the shell script, it's
the name of a subdirectory (of the current directory) where
to put the result files.
frame-%d.png is a pattern for the names of the result files.
The %d stands for the frame number, so the files are called
frame-0.png, frame-1.png, frame-2.png, etc...
Since $1 and $2 are not quoted, they may also contain
other whitespace separated options with arbitrary effects.
Passing parameters this way is unsafe and should at least
be validated.
Home |
Main Index |
Thread Index |
Old Index