Ask a Question related to Debian, Design and Development.
-
Shaul Karl #1
Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
Package: bash
Version: 2.05b-8.1
According to my understanding of the manual page,
$ MY_ENV=abc printf "${MY_ENV}\n"
Should have print abc. But it does not:
$ MY_ENV=abc printf "${MY_ENV}\n"
$
What am I missing?
-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux rakefet 2.4.21-3.custom586.1 #1 Fri Aug 1 21:48:39 IDT 200
Locale: LANG=C, LC_CTYPE=C
Versions of packages bash depends on:
ii base-files 3.0.8 Debian base system miscella
ii libc6 2.3.1-16 GNU C Library: Shared libra
ii libncurses5 5.3.20030510-2 Shared libraries for termin
-- no debconf information
--
Shaul Karl, shaul @ actcom . net . il
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
Shaul Karl Guest
-
#39479 [NEW]: printf ("%4.0f", -0.5) gives answer -1, instead of zero
From: hjblik at hjb-ict dot com Operating system: linux PHP version: 4.4.4 PHP Bug Type: Math related Bug description: ... -
How to make "Print page" and "Print Chapter" buttons
Hi my name is Jaco and I am a multimedia designer who uses Macromedia Director and Flash to create multimedia presentations. I have a request from a... -
Grey when I "export", black when I "print to Distiller"
When I export my B&W ad, designed in InDesign 2.0.2, all the solid black areas in the resulting PDF are actually greyish-black. But if I send the... -
Can't choose "page setup" or "print" - Mac OS 9x
Hello I have a problem on multiple Macs when using Freehand 10. I have not found any answers on macromedia Support or on the web. Before... -
Need Code for "Print This Page" "Print This Table"
I need the code for "Print This Page" and especially for "Print This Table." I want to put this as a "link" from my main page. As is, if I... -
iain d broadfoot #2
Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
* Shaul Karl (shaul@actcom.net.il) wrote:
an 'export' and a ';', like so:> Package: bash
> Version: 2.05b-8.1
>
> According to my understanding of the manual page,
>
> $ MY_ENV=abc printf "${MY_ENV}\n"
>
> Should have print abc. But it does not:
>
> $ MY_ENV=abc printf "${MY_ENV}\n"
>
> $
>
> What am I missing?
$ export MY_ENV=abc ; printf "${MY_ENV}\n"
abc
iain
--
wh33, y1p33 3tc.
"If sharing a thing in no way diminishes it, it is not rightly owned if it is
not shared." -St. Augustine
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
iain d broadfoot Guest
-
iain d broadfoot #3
Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
* Shaul Karl (shaul@actcom.net.il) wrote:
i can't see in the man page an example like the one you show, what> On Sat, Aug 02, 2003 at 10:22:19PM +0100, iain d broadfoot wrote:>> > * Shaul Karl (shaul@actcom.net.il) wrote:> >> > > Package: bash
> > > Version: 2.05b-8.1
> > >
> > > According to my understanding of the manual page,
> > >
> > > $ MY_ENV=abc printf "${MY_ENV}\n"
> > >
> > > Should have print abc. But it does not:
> > >
> > > $ MY_ENV=abc printf "${MY_ENV}\n"
> > >
> > > $
> > >
> > > What am I missing?
> > an 'export' and a ';', like so:
> >
> > $ export MY_ENV=abc ; printf "${MY_ENV}\n"
> > abc
> >
>
> Your proposal has some side effects which might be undesirable. More
> specifically, with your proposal MY_ENV will be set until you
> explicitly unset it or exit the shell. With what I tried to do, MY_ENV
> will only be set for the following command. There will be no need to
> explicitly unset it or exit the shell in order for it to disappear
> afterwards. In addition, the construct I am trying to use is a well
> known construct and the man page says it should work. Is it a bug?
section is it in?
i get the same results as you.> Can you try on your machine the line that I have asked about and see
> if that is working for you? What version of bash are you using?
the other respondent explained the reason for the (apparent) problem, i
think.
iain
--
wh33, y1p33 3tc.
"If sharing a thing in no way diminishes it, it is not rightly owned if it is
not shared." -St. Augustine
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
iain d broadfoot Guest
-
Shaul Karl #4
Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
On Sat, Aug 02, 2003 at 10:22:19PM +0100, iain d broadfoot wrote:
> * Shaul Karl (shaul@actcom.net.il) wrote:>> > Package: bash
> > Version: 2.05b-8.1
> >
> > According to my understanding of the manual page,
> >
> > $ MY_ENV=abc printf "${MY_ENV}\n"
> >
> > Should have print abc. But it does not:
> >
> > $ MY_ENV=abc printf "${MY_ENV}\n"
> >
> > $
> >
> > What am I missing?
> an 'export' and a ';', like so:
>
> $ export MY_ENV=abc ; printf "${MY_ENV}\n"
> abc
>
Your proposal has some side effects which might be undesirable. More
specifically, with your proposal MY_ENV will be set until you
explicitly unset it or exit the shell. With what I tried to do, MY_ENV
will only be set for the following command. There will be no need to
explicitly unset it or exit the shell in order for it to disappear
afterwards. In addition, the construct I am trying to use is a well
known construct and the man page says it should work. Is it a bug?
Can you try on your machine the line that I have asked about and see
if that is working for you? What version of bash are you using?
--
Shaul Karl, shaul @ actcom . net . il
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
Shaul Karl Guest
-
Shaul Karl #5
Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
On Sat, Aug 02, 2003 at 11:55:03PM +0100, iain d broadfoot wrote:
>
> i can't see in the man page an example like the one you show, what
> section is it in?
>
Quoting the ENVIRONMENT section:
The environment for any simple command or function may be augmented
temporarily by prefixing it with parameter assignments, as described
above in PARAMETERS. These assignment statements affect only the envi-
ronment seen by that command.
--
Shaul Karl, shaul @ actcom . net . il
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
Shaul Karl Guest
-
Shawn Lamson #6
Re: Doesn't MY_ENV=abc printf "${MY_ENV}\n" suppose to print abc?
On Sat, August 02 at 12:08 PM EDT
Dave Carrigan <dave@rudedog.org> wrote:
Can you elaborate a little more on this? I am curious, too. After>On Sat, Aug 02, 2003 at 08:49:36PM +0300, Shaul Karl wrote:
>>>> According to my understanding of the manual page,
>>
>> $ MY_ENV=abc printf "${MY_ENV}\n"
>>
>> Should have print abc. But it does not:
>>
>> $ MY_ENV=abc printf "${MY_ENV}\n"
>>
>> What am I missing?
>The "MY_ENV=abc printf" syntax sets the environment variable for the
>printf subprocess. And, in fact, when printf runs, MY_ENV is truly set
>to abc. However, the "${MY_ENV}\n" is expanded *before* printf is
>executed, and since MY_ENV is not set in the existing shell, the
>expansion results in an empty string. The printf command doesn't even
>see MY_ENV in its arguments, all it sees is a single argument that
>looks like ``\n''.
reading your email I tried this:
slamson@callerio:~$ unset COMMAND
slamson@callerio:~$ COMMAND="printf" $COMMAND "x${COMMAND}\n"
bash: x\n: command not found
slamson@callerio:~$ COMMAND="printf" && $COMMAND "x${COMMAND}\n"
xprintf
slamson@callerio:~$
So it seems that the variable is not assigned even for the subprocess.
Does the shell see programs to execute before it looks to do variable
substitution? I know the first things it sees are pipes and redirects
but I don't know more.
I must admit I had never thought of just running a command
after an assignment so it has never come up. "Bug hunting" is great, but
if the OP needs a solution for something, what about this:
slamson@callerio:~$ unset MY_ENV slamson@callerio:~$ (MY_ENV=abc &&
printf "x${MY_ENV}\n") xabc
slamson@callerio:~$ echo x$MY_ENV
x
slamson@callerio:~$
The parens make a subshell which is the "new environment" I assume the
the man page is talking about, right?
Thank you,
Shawn Lamson
[email]shawn.lamson@verizon.net[/email]
--
To UNSUBSCRIBE, email to [email]debian-user-request@lists.debian.org[/email]
with a subject of "unsubscribe". Trouble? Contact [email]listmaster@lists.debian.org[/email]
Shawn Lamson Guest



Reply With Quote

