hp ux - Hp-Ux.Shell.Using variables in "if" -


recently i've got confused following situation. difference between 2 if usage:

case 1

amount=10   if [[ $amount -eq 10 ]]          echo "something"   fi   

script output:

$ ./1.sh     

case 2

if [[ amount -eq 10 ]]    

this works (note variable name doesn't contain $).

so question how work without dollar sign in variable name.

p.s. i'm using posix shell on hp-ux.

man bash

arithmetic evaluation ... shell variables allowed operands; parameter expansion per‐ formed before expression evaluated. within expression, shell variables may referenced name without using parameter expansion syntax.

in context shell not expect numerics, expands strings variables. makes sense me.


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -