Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From the <a href="http://linux.die.net/man/1/bash" rel="nofollow">man page for bash</a>, regarding <code>eval</code>:</p> <blockquote> <p>eval [arg ...]: The args are read and concatenated together into a single command. This command is then read and executed by the shell, and its exit status is returned as the value of eval.</p> </blockquote> <p>When <code>c</code> is defined as <code>"\"/bin/ls\" arf"</code>, the outer quotes will cause <em>the entire thing</em> to be processed as the first argument to <code>eval</code>, which is expected to be a command or program. You need to pass your <code>eval</code> arguments in such a way that the target command and its arguments are listed separately.</p> <p>The <code>$(...)</code> construct behaves differently than <code>eval</code> because it is not a command that takes arguments. It can process the entire command at once instead of processing arguments one at a time.</p> <p>A note on your original premise: The main reason that people say that <code>eval</code> is evil was because it is commonly used by scripts to execute a user-provided string as a shell command. While handy at times, this is a <strong>major</strong> security problem (there's typically no practical way to safety-check the string before executing it). The security problem doesn't apply if you are using <code>eval</code> on hard-coded strings inside your script, as you are doing. However, it's typically easier and cleaner to use <code>$(...)</code> or <code>`...`</code> inside of scripts for command substitution, leaving no real use case left for <code>eval</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload