bash how to input * from a file -


the problem: have simple compiler compiles simple rpn expression. compiler invoked this:

./compiler 1 2 3 + "*" 

this works fine.

now, let's i've put

1 2 3 + "*"  

into file called input. when invoke compiler this:

./compiler $(cat input) 

my compiler complain: unknown symbol: "*"

if remove double quote around *, * gets expanded file names. i've tried '' , ``, no good.

so, how can input normal * file?

zoo.sh content

#!/bin/bash set -f echo $@ 

m.txt content:

1 2 3 + * 

in shell do:

set -f   ./zoo.sh 1 2 4 + * 1 2 4 + *  ./zoo.sh $(cat m.txt) 1 2 3 + * 

the shell doing expansion you. happens before command runs. if want stop need explicitly tell it. read here: http://www.gnu.org/software/bash/manual/bash.html#the-set-builtin

above script sets prevent echo inside script expansion , make work imagine code works. compiler not (need) this.

remember set +f restore filename expansion.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -