Re: [vox-tech] ksh question

2002-01-28 Thread Jay Strauss

I going to (have) avoided the mess, but altering the script I didn't want to
alter


- Original Message -
From: "Jeff Newmiller" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, January 28, 2002 1:44 PM
Subject: Re: [vox-tech] ksh question


> On Mon, 28 Jan 2002, Jay Strauss wrote:
>
> > Sorry Jeff, You weren't talking to yourself, I wasn't around this
weekend
> >
> > To continue your example:
> >
> > $ var=value
> > $ ref=var
> > $ echo ${!ref}
> > value
> > $ var=newvalue
> > echo ${!ref}
> > ??
>
>   $ echo ${!ref}
>   newvalue
>
> >
> > I don't have bash at work so I can't determine what the output is of the
> > above.  I'm running ksh on an HP, and the ${!ref} doesn't work
>
> Well, you still have the messy alternative I mentioned in my first
> message.
>
> >
> > Thanks
> > Jay
> >
> >
> > - Original Message -
> > From: "Jeff Newmiller" <[EMAIL PROTECTED]>
> > To: "vox-tech" <[EMAIL PROTECTED]>
> > Sent: Saturday, January 26, 2002 10:49 PM
> > Subject: Re: [vox-tech] ksh question
> >
> >
> > > Sorry to carry on a conversation with myself, but I said...
> > >
> > > On Sat, 26 Jan 2002, Jeff Newmiller wrote:
> > >
> > > [...]
> > >
> > > > In bash, you can do:
> > > >
> > > >   $ var=value
> > > >   $ ref=var
> > > >   $ echo ${!ref}
> > > >   value
> > > >
> > > > but unfortunately, you cannot do
> > > >
> > > >   $ ${!ref}=anothervalue
> > >
> > > and after experimenting further, I find that the effect can be
obtained
> > > with:
> > >
> > >   $ eval $ref=other
> > >   $ echo $var
> > >   other
> > >
> > > This is still more like a pointer in C than a reference in C++.
> > >
> >
> --
> > -
> > > Jeff NewmillerThe .   .  Go
> > Live...
> > > DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live
> > Go...
> > >   Live:   OO#.. Dead: OO#..
Playing
> > > Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> > > /Software/Embedded Controllers)   .OO#.   .OO#.
> > rocks...2k
> >
> --
> > -
> > >
> > > ___
> > > vox-tech mailing list
> > > [EMAIL PROTECTED]
> > > http://lists.lugod.org/mailman/listinfo/vox-tech
> >
> >
> > _
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> > ___
> > vox-tech mailing list
> > [EMAIL PROTECTED]
> > http://lists.lugod.org/mailman/listinfo/vox-tech
> >
>
> --
-
> Jeff NewmillerThe .   .  Go
Live...
> DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live
Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.
rocks...2k
> --
-
>
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-28 Thread Jeff Newmiller

On Mon, 28 Jan 2002, Jay Strauss wrote:

> Sorry Jeff, You weren't talking to yourself, I wasn't around this weekend
> 
> To continue your example:
> 
> $ var=value
> $ ref=var
> $ echo ${!ref}
> value
> $ var=newvalue
> echo ${!ref}
> ??

  $ echo ${!ref}
  newvalue

> 
> I don't have bash at work so I can't determine what the output is of the
> above.  I'm running ksh on an HP, and the ${!ref} doesn't work

Well, you still have the messy alternative I mentioned in my first
message.

> 
> Thanks
> Jay
> 
> 
> - Original Message -
> From: "Jeff Newmiller" <[EMAIL PROTECTED]>
> To: "vox-tech" <[EMAIL PROTECTED]>
> Sent: Saturday, January 26, 2002 10:49 PM
> Subject: Re: [vox-tech] ksh question
> 
> 
> > Sorry to carry on a conversation with myself, but I said...
> >
> > On Sat, 26 Jan 2002, Jeff Newmiller wrote:
> >
> > [...]
> >
> > > In bash, you can do:
> > >
> > >   $ var=value
> > >   $ ref=var
> > >   $ echo ${!ref}
> > >   value
> > >
> > > but unfortunately, you cannot do
> > >
> > >   $ ${!ref}=anothervalue
> >
> > and after experimenting further, I find that the effect can be obtained
> > with:
> >
> >   $ eval $ref=other
> >   $ echo $var
> >   other
> >
> > This is still more like a pointer in C than a reference in C++.
> >
> > --
> -
> > Jeff NewmillerThe .   .  Go
> Live...
> > DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live
> Go...
> >   Live:   OO#.. Dead: OO#..  Playing
> > Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> > /Software/Embedded Controllers)   .OO#.   .OO#.
> rocks...2k
> > --
> -
> >
> > ___
> > vox-tech mailing list
> > [EMAIL PROTECTED]
> > http://lists.lugod.org/mailman/listinfo/vox-tech
> 
> 
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech
> 

---
Jeff NewmillerThe .   .  Go Live...
DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...2k
---

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-28 Thread Jay Strauss

Sorry Jeff, You weren't talking to yourself, I wasn't around this weekend

To continue your example:

$ var=value
$ ref=var
$ echo ${!ref}
value
$ var=newvalue
echo ${!ref}
??

I don't have bash at work so I can't determine what the output is of the
above.  I'm running ksh on an HP, and the ${!ref} doesn't work

Thanks
Jay


- Original Message -
From: "Jeff Newmiller" <[EMAIL PROTECTED]>
To: "vox-tech" <[EMAIL PROTECTED]>
Sent: Saturday, January 26, 2002 10:49 PM
Subject: Re: [vox-tech] ksh question


> Sorry to carry on a conversation with myself, but I said...
>
> On Sat, 26 Jan 2002, Jeff Newmiller wrote:
>
> [...]
>
> > In bash, you can do:
> >
> >   $ var=value
> >   $ ref=var
> >   $ echo ${!ref}
> >   value
> >
> > but unfortunately, you cannot do
> >
> >   $ ${!ref}=anothervalue
>
> and after experimenting further, I find that the effect can be obtained
> with:
>
>   $ eval $ref=other
>   $ echo $var
>   other
>
> This is still more like a pointer in C than a reference in C++.
>
> --
-
> Jeff NewmillerThe .   .  Go
Live...
> DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live
Go...
>   Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
> /Software/Embedded Controllers)   .OO#.   .OO#.
rocks...2k
> --
-
>
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-26 Thread Jeff Newmiller

Sorry to carry on a conversation with myself, but I said...

On Sat, 26 Jan 2002, Jeff Newmiller wrote:

[...]

> In bash, you can do:
> 
>   $ var=value
>   $ ref=var
>   $ echo ${!ref}
>   value
> 
> but unfortunately, you cannot do
> 
>   $ ${!ref}=anothervalue

and after experimenting further, I find that the effect can be obtained
with:

  $ eval $ref=other
  $ echo $var
  other

This is still more like a pointer in C than a reference in C++.

---
Jeff NewmillerThe .   .  Go Live...
DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...2k
---

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-25 Thread Jeff Newmiller

On Fri, 25 Jan 2002, Jay Strauss wrote:

> Ok, a question guaranteed not to get flamed, or start a war.
> 
> I want one environmental variable to equal another (dynamically all the
> time) but I can't figure it out.  That is I want the behavior of:
> 
> export PS1='$PWD'

This behavior is well-defined... PS1 expands to a dollar sign followed by
PWD.  What is also well-defined, but may not behave in the fashion you
seem to want, is the subsequent expansion by BASH of the contents of this
variable before display.  That is, you always have to evaluate the
contents of the variable, as well as evaluating the variable.

> For example, this is what I'd like to happen (though I can't get it to
> work):
> 
> pete=one
> repeat=$pete
> echo $repeat
> one
> pete=two
> echo $repeat
> two

In bash, you can do:

  $ var=value
  $ ref=var
  $ echo ${!ref}
  value

but unfortunately, you cannot do

  $ ${!ref}=anothervalue

(see http://www.linuxdoc.org/LDP/abs/html/bash2.html#EX78)

I don't know ksh, but playing around with it I find:

  $ echo `eval 'echo $'$ref`
  value

seems to work.

Thus, the script receiving the indirect reference variable must be
constructed to handle the indirection.

You probably wouldn't want to be doing this with an suid script... you
could find yourself evaluating unfriendly shell code. :(

---
Jeff NewmillerThe .   .  Go Live...
DCN:<[EMAIL PROTECTED]>Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...2k
---




___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-25 Thread nbs

On Fri, Jan 25, 2002 at 06:55:56AM -0800, Stephen M. Helms wrote:
> nbs wrote:
> {snip}
> 
> > Only times I ever use ksh is when logging into Sun servers at work,
> > and I don't do any shell scripting on them.  (I really miss the
> > tcsh/bash features I got used to, too...)
> 
> Why not just type bash, tcsh, sh, csh, etc... after you log into the Sun
> server at work?

bash environment is borked.  (won't get into that :) )

hey, tcsh seems to work, tho! :)  at least, at first glance. :)

-bill!
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-25 Thread Stephen M. Helms

nbs wrote:
{snip}

> Only times I ever use ksh is when logging into Sun servers at work,
> and I don't do any shell scripting on them.  (I really miss the
> tcsh/bash features I got used to, too...)

Why not just type bash, tcsh, sh, csh, etc... after you log into the Sun
server at work?
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-25 Thread nbs

On Fri, Jan 25, 2002 at 04:38:03PM -0600, Jay Strauss wrote:
> I guess its guaranteed not to get any response either :(

Sorry ;)

Only times I ever use ksh is when logging into Sun servers at work,
and I don't do any shell scripting on them.  (I really miss the
tcsh/bash features I got used to, too...)

-bill!
___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech



Re: [vox-tech] ksh question

2002-01-25 Thread Jay Strauss

I guess its guaranteed not to get any response either :(

- Original Message - 
From: "Jay Strauss" <[EMAIL PROTECTED]>
To: "vox-tech" <[EMAIL PROTECTED]>
Sent: Friday, January 25, 2002 11:29 AM
Subject: [vox-tech] ksh question


> Ok, a question guaranteed not to get flamed, or start a war.
> 
> I want one environmental variable to equal another (dynamically all the
> time) but I can't figure it out.  That is I want the behavior of:
> 
> export PS1='$PWD'
> 
> For example, this is what I'd like to happen (though I can't get it to
> work):
> 
> pete=one
> repeat=$pete
> echo $repeat
> one
> pete=two
> echo $repeat
> two
> 
> 
> Thanks
> Jay
> 
> 
> 
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> ___
> vox-tech mailing list
> [EMAIL PROTECTED]
> http://lists.lugod.org/mailman/listinfo/vox-tech


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___
vox-tech mailing list
[EMAIL PROTECTED]
http://lists.lugod.org/mailman/listinfo/vox-tech