Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

C shell question

#!/bin/csh
setenv caller "enviroment1"
echo $caller
setenv caller "enviroment2"
echo $caller
set caller="ordinary1"
echo $caller
set caller="ordinary2"
echo $caller

output is

enviroment1
enviroment2
ordinary1


But

#!/bin/csh
setenv caller "enviroment1"
echo $caller
setenv caller "enviroment2"
echo $caller
set caller="ordinary1"
echo $caller
set caller="ordinary2"
echo $caller
printenv $caller

output is

enviroment1
enviroment2
ordinary1
ordinary2

Why?

thanks
0
tiger0516
Asked:
tiger0516
  • 2
1 Solution
 
TintinCommented:
printenv is a csh builtin, and echo is an external command that will only see exported variables (ie: setenv)
0
 
gheistCommented:
printenv takes variable name as parameter.

"printenv caller" will display value for instance.
0
 
ahoffmannCommented:
man csh
man printenv

csh distinguishes between shell and environment variables, hence
  setenv caller
sets another variable than
  set caller=
csh has 2 separate name spaces (just PATH/path and TERM/term are the same)
printenv prints only environment variables, obviously you see the settings done with setenv
echo ist a dragon, in particular in this case it's unreliable (means depends on a couple of other things to give an answer here)
0
 
gheistCommented:
It looks like first command sequence misses eol after last line...
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now