help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] avoiding shell variable expansion


From: Greg Silverman
Subject: [Help-bash] avoiding shell variable expansion
Date: Thu, 3 Oct 2019 19:47:42 +0000

In Python one  can spawn a child process and avoid bash expanding command line 
arguments, e.g.

//file: ls.py
import subprocess
proc = subprocess.Popen(['/bin/ls','*'],shell=False)

then
./ls.py
/bin/ls: cannot access '*': No such file or directory

As the shell argument is set to False, the ls command is not passed to bash 
before being executed and the star is not expanded to ${PWD}.

Is there a way to launch a command from a bash script which, also, avoids shell 
expansion? This question is for security, to avoid code injection.

Thanks,

Greg Silverman
Principal Engineer
Veritas Technologies
Santa Clara, CA



reply via email to

[Prev in Thread] Current Thread [Next in Thread]