Commit Graph

14 Commits

Author SHA1 Message Date
brian m. carlson
899168eb50 tools: move ShellQuote to subprocess
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.
2018-09-14 21:50:09 +00:00
brian m. carlson
69b534ece0 tools: add function to perform shell quoting
In certain cases, such as the GIT_SSH_COMMAND environment variable,
we'll need to pass data to the shell.  Since some of our arguments
contain spaces, we'll need to quote those values.  Introduce a function
to quote strings so that they're suitable for the shell.  For
simplicity's sake, assume anything beyond identifier characters, dot, at
sign, and hyphen-minus needs to be quoted and use single quotes for
doing so.  Handle single quotes in a string in the same way as Git does.
2018-09-04 15:02:41 +00:00
Taylor Blau
3705794493 tools: introduce tools.Undent() to remove leading tabs, spaces 2017-07-06 11:59:43 -07:00
Taylor Blau
75fde77dda tools: introduce tools.Indent() to indent strings 2017-07-06 11:59:43 -07:00
Taylor Blau
481c6beeb3 tools: ensure Longest() is called 2017-06-13 16:05:34 -06:00
Taylor Blau
bea1d63f68 tools: implement tools.Ljust 2017-06-13 16:00:08 -06:00
Taylor Blau
4f1ae98508 tools: implement tools.Rjust([]string{...}) 2017-06-13 16:00:07 -06:00
Taylor Blau
5b573e2592 tools: implement tools.Longest 2017-06-13 14:52:08 -06:00
Taylor Blau
50386ad374 tools/str_test: use `` to make reading escaped-quotes easier 2017-02-21 11:50:55 -07:00
Taylor Blau
a35f0759de tools: handle empty pairs of balanced quotes
If a quote is empty on its own, i.e., '', match an empty string. Otherwise, if
the quote is empty and inside another set of balanced quotes, treat it as-is,
i.e., "foo """ matches []string{"foo \"\""}.
2017-02-21 11:45:52 -07:00
Taylor Blau
7ec512c72f tools: omit outer quotes quotes in matches 2017-02-21 11:32:28 -07:00
Taylor Blau
4a25341669 tools/str_tools: remove use of t.Run to build below Go1.8 2017-02-21 09:53:20 -07:00
Taylor Blau
20618fd311 tools/str_test: demote case description out of struct 2017-02-19 13:02:39 -07:00
Taylor Blau
9a73171f21 tools: implement tools.QuotedFields 2017-02-18 15:46:11 -07:00