We currently have a function to shell quote a list of strings, but in
some cases we may want to just quote a single string. To avoid the
complexity of having to create a bunch of temporaries and then index out
the result, create a function that shell quotes just a single string.
There are a small number of places where we'll want to pass data to the
shell. Add a function which formats a command name and arguments into a
command that invokes "sh -c" with the appropriate args. Additionally
add a form that quotes its arguments, and use this in the SSH code,
which wants to pass data to the shell.
Add the slash to the list of characters which don't require quoting for
the shell. No POSIX-compatible shell requires escaping the slash, and
ignoring it for the purposes of escaping lets us write cleaner,
nicer-to-read trace output.
Don't do the same with the backslash, which while being the equivalent
on Windows, is handled specially by POSIX shells.
In a future commit, we'll be adding some additional shell-related
handling which logically belongs to the subprocess package. To avoid an
import loop, move the ShellQuote function and its required variable from
the tools package to the subprocess package. Update the only caller of
this function.
This commit contains no functional change.
Replicate `lfs/gitscanner_cmd` in `subprocess/buffered_cmd` using
subprocess/cmd. In subsequent commits we will migrate all functions
users of `lfs/gitscanner_cmd` to `subprocess/buffered_cmd` and
afterwards remove `lfs/gitscanner_cmd`.
This commit copies-down some utility methods introduced as part of the API change in Go 1.6. These changes are convenient to use here, since they auto-truncate stderr error output.
Revert this commit when moving to Go 1.6.
ExitError conditions now return a plain error with message like:
Error running git [config --system filter.lfs.clean git-lfs clean -- %f]: 'error: could not lock config file /etc/gitconfig: Permission denied' 'exit status 255'
Also:
* Made Set/Unset Config commands return errors when they occur.
* Made install attribute set fail properly with an error message e.g. if permission-denied. Previously this failed silently and reported success.
***NOTE*** this commit contains Go 1.6-specific APIs. The following commit will remove those, and that following commit can be reverted when Go >= 1.6 is required.