mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-09 15:37:56 -05:00
Escape some bash special characters being passed to bash via system. (#6543)
This commit is contained in:
@@ -164,13 +164,19 @@ class Package
|
||||
{ exception: true }
|
||||
end
|
||||
|
||||
# add -j arg to build commands
|
||||
# Add -j arg to build commands.
|
||||
cmd_args.sub(/\b(?<=make)(?=\b)/, " -j#{CREW_NPROC}") unless cmd_args =~ /-j\s*\d+/
|
||||
# Escape special bash characters.
|
||||
cmd_args.gsub!('"','\\\\"')
|
||||
cmd_args.gsub!('$','\\\\$')
|
||||
cmd_args.gsub!('`','\\\\`')
|
||||
|
||||
begin
|
||||
# use bash instead of /bin/sh
|
||||
@system_args = ''
|
||||
[@system_args, "bash -e -c \"#{cmd_args}\""].reduce(&:concat)
|
||||
# Uncomment following line for debugging.
|
||||
# puts @system_args.orange
|
||||
Kernel.system(@system_args, system_options)
|
||||
rescue => e
|
||||
exitstatus = $?.exitstatus
|
||||
|
||||
Reference in New Issue
Block a user