-
Notifications
You must be signed in to change notification settings - Fork 10
command
Specifies a default command to be run for a given config
when no command is given on the command-line.
grammar v0
config default
command "echo Hello there."
end
Cannot be specified outside of a config
statement.
There may not be multiple commands within a given
config
.
You can use the --command-extra-args
option to add parameters to the command.
For example, given the above package declaration, if you were to run fig --command-extra-args It is a nice day.
, you would get "Hello there. It is a
nice day." as output.
Just to be absolutely clear, if the package definition is in the v0 grammar, the command-line will always interpreted by the shell, whereas the shell will or will not be involved based upon how many values are in the command-line sequence in the v1 grammar or later.
The shell used can be specified by the SHELL
or ComSpec
environment
variable.
In the v0 grammar, the command-line must be specified as a single value contained in double quotes and cannot contain double quotes.
grammar v0
config something
command "command-line with the path to package @foo included."
end
The command will be handed through to the shell after
expansion with any values from the
--command-extra-args
option concatenated to the end, separated by space
characters.
v1 grammar and later
In the v1 grammar, the command-line is specified as a sequence of
strings, either bare words or quoted, terminated by a
bare "end
". For the purposes of quoting, at signs are
considered metacharacters, due to package expansion.
grammar v1
config something
command
bare words
'or'
"quoted words with the path to package @foo included."
end
end
config run-date
command date end
end
config list-c-files
command 'ls *.c' end # The shell will interpret this.
end
config list-a_file-named-star.c
command ls *.c end # Will look for a file named "*.c".
end
Each string in the sequence has package expansion
done to it, subject to the standard quoting and escaping.
As with the usual Unix set of exec()
functions, if the sequence consists of a
single value, then that value is passed to the shell to interpret. If the
sequence has more than one value in it, the command is directly invoked with no
shell interpolation.
If the --command-extra-args
option was used, then those values are added to
the end of the sequence.
Note that use of --command-extra-args
guarantees that the command-line will
not go through the shell. This is because the argument sequence will have
multiple values in it. So, if the package definition
file contains
grammar v1
config default
command
"something"
end
end
Then running
fig --run-command-statement
will cause "something"
to be handed to the shell because the sequence
contains only one value, but running
fig --command-extra-args whatever
will cause the shell to not be involved because the command-line sequence has two values in it.