bash - safely pass untrusted strings?

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



In bash, given a string assignment as follows, how do I "add slashes" 
automagically, so that it can be safely passed to another program? Notice 
that the assignment contains spaces, single-quotes and double-quotes, maybe 
god-only-knows-what-else. It's untrusted data. 

Yet I need to pass it all *safely*. 

The appropriate function in PHP is addslashes(); but what is the bash 
equivalent? EG: 


#! /bin/sh 
A="This isn't a \"parameter\""; 
B=`/path/to/somecommand.sh $A`; 
exit 0;


Thanks, 

-Ben 
--
Only those who reach toward a goal are likely to achieve it. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux