1# This file is part of the Astrometry.net suite.
2# Licensed under a 3-clause BSD style license - see LICENSE
3def shell_escape(s):
4    repl = ('\\', '|', '&', ';', '(', ')', '<', '>', ' ', '\t',
5            '\n', '$', "'", '"', "`")
6    # (note, \\ must be first!)
7    for x in repl:
8        s = s.replace(x, '\\'+x)
9    return s
10
11# escape a string that will appear inside double-quotes.
12def shell_escape_inside_quotes(s):
13    repl = ('\\', '\t', '`', '"', '$')
14    # (note, \\ must be first!)
15    for x in repl:
16        s = s.replace(x, '\\'+x)
17    return s
18