Skip to content

Commit

Permalink
Improve handing of dollar sign in Target Shell (#101)
Browse files Browse the repository at this point in the history
(DIS-1697)
  • Loading branch information
cecinestpasunepipe committed Dec 12, 2022
1 parent d1fcfe4 commit 7c6cf2c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions dissect/target/tools/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

# remove `-` as an autocomplete delimeter on Linux
# https://stackoverflow.com/questions/27288340/python-cmd-on-linux-does-not-autocomplete-special-characters-or-symbols
readline.set_completer_delims(readline.get_completer_delims().replace("-", ""))
readline.set_completer_delims(readline.get_completer_delims().replace("-", "").replace("$", ""))
except ImportError:
# Readline is not available on Windows
log.warning("Readline module is not available")
Expand Down Expand Up @@ -146,9 +146,12 @@ def _exec(self, func, command_args_str):
Command execution helper that chains initial command and piped
subprocesses (if any) together
"""
argparts = (
[] if command_args_str is None else list(shlex.shlex(command_args_str, posix=True, punctuation_chars=True))
)

argparts = []
if command_args_str is not None:
lexer = shlex.shlex(command_args_str, posix=True, punctuation_chars=True)
lexer.wordchars += "$"
argparts = list(lexer)

try:
if "|" in argparts:
Expand Down

0 comments on commit 7c6cf2c

Please sign in to comment.