Skip to main content
added 125 characters in body
Source Link
Petr Skocik
  • 29.7k
  • 18
  • 90
  • 155

You can directly eval it:

eval "$(grep -P '^\s*\w+=' config.sh)" #quotes needed if you want the full content of the file (including newlines etc.) 

Sourcing is essentially the same as:

eval "$(cat file)" 

Note, however, that people could be executing all kinz of codez at the right side of the equal sign:

a=$(evil_code_here) b=`evil_code_here` c="something" evil_code_here #etc. 

You need a better filter.

You can directly eval it:

eval "$(grep -P '^\s*\w+=' config.sh)" #quotes needed if you want the full content of the file (including newlines etc.) 

Sourcing is essentially the same as:

eval "$(cat file)" 

Note, however, that people could be executing all kinz of codez at the right side of the equal sign.

You can directly eval it:

eval "$(grep -P '^\s*\w+=' config.sh)" #quotes needed if you want the full content of the file (including newlines etc.) 

Sourcing is essentially the same as:

eval "$(cat file)" 

Note, however, that people could be executing all kinz of codez at the right side of the equal sign:

a=$(evil_code_here) b=`evil_code_here` c="something" evil_code_here #etc. 

You need a better filter.

Source Link
Petr Skocik
  • 29.7k
  • 18
  • 90
  • 155

You can directly eval it:

eval "$(grep -P '^\s*\w+=' config.sh)" #quotes needed if you want the full content of the file (including newlines etc.) 

Sourcing is essentially the same as:

eval "$(cat file)" 

Note, however, that people could be executing all kinz of codez at the right side of the equal sign.