diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-02-10 12:28:34 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-02-10 12:28:34 +0000 |
commit | 694dc0d1d744e20e5bf1722e928afa4cbcb596a0 (patch) | |
tree | c382a84c8c4d59b1162792573d87d5240f9d08a2 | |
parent | 366925616dd4382214cc1444a0105d39a9474259 (diff) | |
download | cliapp-694dc0d1d744e20e5bf1722e928afa4cbcb596a0.tar.gz |
Start a function to safely quote arbitrary strings for shell
-rw-r--r-- | cliapp/__init__.py | 2 | ||||
-rw-r--r-- | cliapp/runcmd.py | 6 | ||||
-rw-r--r-- | cliapp/runcmd_tests.py | 6 |
3 files changed, 13 insertions, 1 deletions
diff --git a/cliapp/__init__.py b/cliapp/__init__.py index fbf1af3..9ab5cc4 100644 --- a/cliapp/__init__.py +++ b/cliapp/__init__.py @@ -21,7 +21,7 @@ __version__ = '1.20121216' from fmt import TextFormat from settings import (Settings, log_group_name, config_group_name, perf_group_name) -from runcmd import runcmd, runcmd_unchecked +from runcmd import runcmd, runcmd_unchecked, shell_quote from app import Application, AppException # The plugin system diff --git a/cliapp/runcmd.py b/cliapp/runcmd.py index 083dbca..081d14b 100644 --- a/cliapp/runcmd.py +++ b/cliapp/runcmd.py @@ -199,3 +199,9 @@ def _run_pipeline(procs, feed_stdin, pipe_stdin, pipe_stdout, pipe_stderr): return procs[-1].returncode, ''.join(out), ''.join(err) + + +def shell_quote(s): + '''Return a shell-quoted version of s.''' + return s + diff --git a/cliapp/runcmd_tests.py b/cliapp/runcmd_tests.py index ede0c3e..8f8a8a9 100644 --- a/cliapp/runcmd_tests.py +++ b/cliapp/runcmd_tests.py @@ -124,3 +124,9 @@ class RuncmdTests(unittest.TestCase): self.assertEqual(exit, 0) self.assertEqual(data, '') + +class ShellQuoteTests(unittest.TestCase): + + def test_returns_empty_string_for_empty_string(self): + self.assertEqual(cliapp.shell_quote(''), '') + |