Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, its a bad, bad, really bad idea to have variable names declared in upper case, especially <code>PATH</code> since you would be actually re-setting the actual <code>PATH</code> environment variable (just do a <code>echo $PATH</code> in the prompt and you will understand what I mean, and this is probably one of the reasons why you had to use <code>/usr/bin/clear</code> instead of <code>clear</code> since the env variable <code>PATH</code> gets modified). So, its always recommended to use variables with lower case like <code>path</code>.</p> <hr> <p>The problem you are facing is with <code>glob</code> expansion of <code>*</code> within the subshell. When you use </p> <pre><code>./script '/home/*/public_html' php.ini module.so </code></pre> <p>the <code>*</code> is not expanded at the prompt (parent shell) but is expanded inside the script's subshell. But when you use</p> <pre><code>./script /home/*/public_html php.ini module.so </code></pre> <p>the <code>*</code> is expanded in the parent shell (which would result in one random path as pointed to by the shell) and then gets passed inside the program subshell-</p> <p>So lets say, <code>/home</code> has directories <code>/user</code>, <code>/apps</code>,<code>/data</code> doing <code>$ cd *</code> would take you to the directory which is alphabetically first i.e. <code>/apps</code>. So <code>/home/*</code> without quotes in the parent shell will always point to <code>/home/apps</code> which is not what we want!</p> <p>An immediate remedy to this is as below</p> <pre><code>$set -o noglob #unset glob expansion $./script /home/*/public_html php.ini module.so #your command without quotes &amp; wildcard */ $set +o noglob #re-set glob expansion back </code></pre> <p>or</p> <pre><code>$set -o noglob;./script /home/*/public_html php.ini module.so;set +o noglob </code></pre> <p>Try <code>$echo *</code> and then <code>$set -o noglob;echo *;set +o noglob</code> for a quick example.</p> <p><strong>Caveat</strong>- if you fail or forget to set <code>noglob</code> back (<code>set +o noglob</code>), the shell will treat characters like <code>*</code> and <code>?</code> like normal characters and will not expand them which might lead to undesirable results and confusion.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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