bash - Seeing shell commands as they are being executed including variables -


this question has answer here:

i can do

bash -x mysellh.sh 

to see commands being executed, don't see variables replaced values. instance, if have in shell script:

screen -d -m sh -c 'rails_env="$r_env" bundle exec rake sunspot:solr:reindex[500] > "$project_dir"/solr/indexing_out.txt' 

i see:

+ screen -d -m sh -c 'rails_env="$r_env" bundle exec rake sunspot:solr:reindex[500] > "$project_dir"/solr/indexing_out.txt' 

even though i've declared earlier:

r_env=test 

is there option want?

in case, doing asked: command line "word" $r_env in have enclosed in single quotes, inhibit expansion. -x output showing non-expansion. if want variables expanded, enclose first "word" in double quotes , use single quotes in contents, this:

screen -d -m sh -c "rails_env='$r_env' bundle exec rake sunspot:solr:reindex[500] > '$project_dir'/solr/indexing_out.txt" 

then single quotes around expanded text , double quotes allow variables expand.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -