public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: Problems with the new base-files-4.0-5?
@ 2011-03-17 23:07 Angelo Graziosi
  2011-03-17 23:41 ` David Sastre
  2011-03-18  2:51 ` Cyrille Lefevre
  0 siblings, 2 replies; 22+ messages in thread
From: Angelo Graziosi @ 2011-03-17 23:07 UTC (permalink / raw)
  To: Cygwin

David Sastre wrote:
> Please test if
>
> [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}

No, I think.

I get:

$ cat test_pr.sh
#!/bin/bash

p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows 
NT/CurrentVersion/Windows/Device'

[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}

echo 'echo $PRINTER'
echo $PRINTER

$ ./test_pr.sh
echo $PRINTER
HP Deskjet 3740 Series,winspool,Ne03:
----------------------^^^^^^^^^^^^^^^
which is *wrong*. See ^^^^^^^^^^^^^^^ above!

With base-files-4.0-4 I get:

$ echo $PRINTER
HP Deskjet 3740 Series

which is right.

Ciao,
Angelo.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 23:07 Problems with the new base-files-4.0-5? Angelo Graziosi
@ 2011-03-17 23:41 ` David Sastre
  2011-03-17 23:46   ` Christopher Faylor
  2011-03-18  2:51 ` Cyrille Lefevre
  1 sibling, 1 reply; 22+ messages in thread
From: David Sastre @ 2011-03-17 23:41 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1146 bytes --]

On Thu, Mar 17, 2011 at 11:43:26PM +0100, Angelo Graziosi wrote:
> David Sastre wrote:
> >Please test if
> >
> >[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
> 
> No, I think.
> 
> I get:
> 
> $ cat test_pr.sh
> #!/bin/bash
> 
> p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
> NT/CurrentVersion/Windows/Device'
> 
> [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
> 
> echo 'echo $PRINTER'
> echo $PRINTER
> 
> $ ./test_pr.sh
> echo $PRINTER
> HP Deskjet 3740 Series,winspool,Ne03:
> ----------------------^^^^^^^^^^^^^^^
> which is *wrong*. See ^^^^^^^^^^^^^^^ above!
> 
> With base-files-4.0-4 I get:
> 
> $ echo $PRINTER
> HP Deskjet 3740 Series
> 
> which is right.
> 
> Ciao,
> Angelo.

Thanks for testing.
It looks like it's easier to solve this with a simple if statement.

p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
if [ -e "${p}" ] ; then
  read -r PRINTER < "${p}"
  PRINTER=${PRINTER%%,*}
fi

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 23:41 ` David Sastre
@ 2011-03-17 23:46   ` Christopher Faylor
  0 siblings, 0 replies; 22+ messages in thread
From: Christopher Faylor @ 2011-03-17 23:46 UTC (permalink / raw)
  To: cygwin

On Fri, Mar 18, 2011 at 12:07:43AM +0100, David Sastre wrote:
>On Thu, Mar 17, 2011 at 11:43:26PM +0100, Angelo Graziosi wrote:
>> David Sastre wrote:
>> >Please test if
>> >
>> >[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
>> 
>> No, I think.
>> 
>> I get:
>> 
>> $ cat test_pr.sh
>> #!/bin/bash
>> 
>> p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
>> NT/CurrentVersion/Windows/Device'
>> 
>> [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
>> 
>> echo 'echo $PRINTER'
>> echo $PRINTER
>> 
>> $ ./test_pr.sh
>> echo $PRINTER
>> HP Deskjet 3740 Series,winspool,Ne03:
>> ----------------------^^^^^^^^^^^^^^^
>> which is *wrong*. See ^^^^^^^^^^^^^^^ above!
>> 
>> With base-files-4.0-4 I get:
>> 
>> $ echo $PRINTER
>> HP Deskjet 3740 Series
>> 
>> which is right.
>> 
>> Ciao,
>> Angelo.
>
>Thanks for testing.
>It looks like it's easier to solve this with a simple if statement.
>
>p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
>if [ -e "${p}" ] ; then
>  read -r PRINTER < "${p}"
>  PRINTER=${PRINTER%%,*}
>fi

How about:

read -r -d, PRINTER < '/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'

I see that "-d" is available in ksh but I don't know about the other shells.

cgf

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 23:07 Problems with the new base-files-4.0-5? Angelo Graziosi
  2011-03-17 23:41 ` David Sastre
@ 2011-03-18  2:51 ` Cyrille Lefevre
  2011-03-18 14:17   ` David Sastre
  1 sibling, 1 reply; 22+ messages in thread
From: Cyrille Lefevre @ 2011-03-18  2:51 UTC (permalink / raw)
  To: cygwin


Le 17/03/2011 23:43, Angelo Graziosi a écrit :

> p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
> NT/CurrentVersion/Windows/Device'
>
> [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}

read -r "$p" returns 1 bcoz "The return code is zero, unless end-of-file 
is encountered"...

alternative :

[ -e "${p}" ] && IFS=',' read -r PRINTER dummy < "${p}"

Regards,

Cyrille Lefevre
-- 
mailto:Cyrille.Lefevre-lists@laposte.net



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18  2:51 ` Cyrille Lefevre
@ 2011-03-18 14:17   ` David Sastre
  2011-03-18 14:31     ` Andy Koppe
                       ` (2 more replies)
  0 siblings, 3 replies; 22+ messages in thread
From: David Sastre @ 2011-03-18 14:17 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2540 bytes --]

On Fri, Mar 18, 2011 at 12:46:26AM +0100, Cyrille Lefevre wrote:
> 
> Le 17/03/2011 23:43, Angelo Graziosi a écrit :
> 
> >p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
> >NT/CurrentVersion/Windows/Device'
> >
> >[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
> 
> read -r "$p" returns 1 bcoz "The return code is zero, unless
> end-of-file is encountered"...
> 
> alternative :
> 
> [ -e "${p}" ] && IFS=',' read -r PRINTER dummy < "${p}"

Works in bash, posh, mksh and zsh, but fails (at least for me) in
dash.
As it seems I can't find a short-circuiting option that works, I'll
use the `if' statement, since it appears to work for all shells.

All [[, have been changed to a portable [ test.
I've changed `test -a' for a portable `test -e', and the -a operator
in the user's home ownership test to a chained test:

elif [ ! -O "${HOME}" ] && [ "${HOME#/home/}" != "${HOME}" ]; then ...

which works for all shells but still fails for posh since posh does
not implement the -O test either (as per POSIX compliance, right?). 
This is not easy to solve without rethinking that test, so I plan to 
release 4.0-6 with this known bug, with the following workaround: 
the code block that sets $HOME is now enclosed in a function that 
tests for posh and returns before the ownership test.
The functionality is lost for those who use posh as a login shell (hopefully,
not too many...).
It would be included in the announcement message as well.

This has to be reported to the posh maintainer as well, but:

a) As stated in the manpage, posh -li should read /etc/profile, but it
doesn't (and that's why it doesn't complain about [[ presence in
/etc/profile)

b) It fails to source some of the /etc/profile.d/*.sh scripts due to not
finding its documented alias builtin:

$ . /etc/profile.d/mc.sh
posh: /etc/profile.d/mc.sh:1: alias: not found
$ builtin alias
posh: builtin: alias: not a builtin

To workaround this, posh won't source them, it's been explicitly disabled.

c) $POSH_VERSION returns literally "POSH_VERSION" (FWIW, both in cygwin
and GNU/Linux), instead of its version identifier, as bash and mksh do.
Maybe it's the expected (though uninformative) behaviour or a known
bug.

Last, can someone confirm that calling `dash -i' from mksh results in 
`dash: Bad substitution' errors? (IOW, make mksh your login shell, and
run dash -i from your prompt).

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18 14:17   ` David Sastre
@ 2011-03-18 14:31     ` Andy Koppe
  2011-03-18 16:28       ` David Sastre
  2011-03-18 16:20     ` Nellis, Kenneth
  2011-03-20  9:19     ` IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?) Cyrille Lefevre
  2 siblings, 1 reply; 22+ messages in thread
From: Andy Koppe @ 2011-03-18 14:31 UTC (permalink / raw)
  To: cygwin

On 18 March 2011 13:46, David Sastre wrote:
> All [[, have been changed to a portable [ test.
> I've changed `test -a' for a portable `test -e', and the -a operator
> in the user's home ownership test to a chained test:
>
> elif [ ! -O "${HOME}" ] && [ "${HOME#/home/}" != "${HOME}" ]; then ...

Even though that home ownership test was partly my idea, I think it
should simply be dropped, because it doesn't actually address the
security issue it was supposed to address and the warning is likely to
cause unnecessary alarm to users with unusual yet legitimate setups.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: Problems with the new base-files-4.0-5?
  2011-03-18 14:17   ` David Sastre
  2011-03-18 14:31     ` Andy Koppe
@ 2011-03-18 16:20     ` Nellis, Kenneth
  2011-03-18 16:41       ` David Sastre
  2011-03-20  9:19     ` IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?) Cyrille Lefevre
  2 siblings, 1 reply; 22+ messages in thread
From: Nellis, Kenneth @ 2011-03-18 16:20 UTC (permalink / raw)
  To: cygwin

From: David Sastre
> On Fri, Mar 18, 2011 at 12:46:26AM +0100, Cyrille Lefevre wrote:
> >
> > Le 17/03/2011 23:43, Angelo Graziosi a écrit :
> >
> > >p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows
> > >NT/CurrentVersion/Windows/Device'
> > >
> > >[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
> >
> > read -r "$p" returns 1 bcoz "The return code is zero, unless
> > end-of-file is encountered"...
> >
> > alternative :
> >
> > [ -e "${p}" ] && IFS=',' read -r PRINTER dummy < "${p}"
> 

While you're at it, it would probably be a good idea to:
$ unset p
when you're done with it.

--Ken Nellis

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18 14:31     ` Andy Koppe
@ 2011-03-18 16:28       ` David Sastre
  2011-03-18 16:43         ` Andy Koppe
  0 siblings, 1 reply; 22+ messages in thread
From: David Sastre @ 2011-03-18 16:28 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 856 bytes --]

On Fri, Mar 18, 2011 at 02:17:14PM +0000, Andy Koppe wrote:
> On 18 March 2011 13:46, David Sastre wrote:
> > All [[, have been changed to a portable [ test.
> > I've changed `test -a' for a portable `test -e', and the -a operator
> > in the user's home ownership test to a chained test:
> >
> > elif [ ! -O "${HOME}" ] && [ "${HOME#/home/}" != "${HOME}" ]; then ...
> 
> Even though that home ownership test was partly my idea, I think it
> should simply be dropped, because it doesn't actually address the
> security issue it was supposed to address and the warning is likely to
> cause unnecessary alarm to users with unusual yet legitimate setups.

IIRC, the point was that some apps expect $HOME to be owned by the
user in order to operate correctly.

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18 16:20     ` Nellis, Kenneth
@ 2011-03-18 16:41       ` David Sastre
  0 siblings, 0 replies; 22+ messages in thread
From: David Sastre @ 2011-03-18 16:41 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 369 bytes --]

On Fri, Mar 18, 2011 at 11:14:09AM -0500, Nellis, Kenneth wrote:
> While you're at it, it would probably be a good idea to:
> $ unset p
> when you're done with it.

Indeed. Already applied. In fact, there was another one (fDest, used in a 
loop to copy skel files).

Thanks.

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18 16:28       ` David Sastre
@ 2011-03-18 16:43         ` Andy Koppe
  2011-03-18 18:02           ` David Sastre
  0 siblings, 1 reply; 22+ messages in thread
From: Andy Koppe @ 2011-03-18 16:43 UTC (permalink / raw)
  To: cygwin

On 18 March 2011 16:23, David Sastre wrote:
> On Fri, Mar 18, 2011 at 02:17:14PM +0000, Andy Koppe wrote:
>> On 18 March 2011 13:46, David Sastre wrote:
>> > All [[, have been changed to a portable [ test.
>> > I've changed `test -a' for a portable `test -e', and the -a operator
>> > in the user's home ownership test to a chained test:
>> >
>> > elif [ ! -O "${HOME}" ] && [ "${HOME#/home/}" != "${HOME}" ]; then ...
>>
>> Even though that home ownership test was partly my idea, I think it
>> should simply be dropped, because it doesn't actually address the
>> security issue it was supposed to address and the warning is likely to
>> cause unnecessary alarm to users with unusual yet legitimate setups.
>
> IIRC, the point was that some apps expect $HOME to be owned by the
> user in order to operate correctly.

Originally at least it was supposed to address this:

http://www.cygwin.com/ml/cygwin-developers/2010-09/msg00007.html

The $HOME warning doesn't address this because for example a
maliciously prepared /home/$USER/.bash_profile would still get
sourced.

I can't remember other reasons.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-18 16:43         ` Andy Koppe
@ 2011-03-18 18:02           ` David Sastre
  0 siblings, 0 replies; 22+ messages in thread
From: David Sastre @ 2011-03-18 18:02 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

On Fri, Mar 18, 2011 at 04:41:49PM +0000, Andy Koppe wrote:
> On 18 March 2011 16:23, David Sastre wrote:
> > On Fri, Mar 18, 2011 at 02:17:14PM +0000, Andy Koppe wrote:
> >> On 18 March 2011 13:46, David Sastre wrote:
> >> > All [[, have been changed to a portable [ test.
> >> > I've changed `test -a' for a portable `test -e', and the -a operator
> >> > in the user's home ownership test to a chained test:
> >> >
> >> > elif [ ! -O "${HOME}" ] && [ "${HOME#/home/}" != "${HOME}" ]; then ...
> >>
> >> Even though that home ownership test was partly my idea, I think it
> >> should simply be dropped, because it doesn't actually address the
> >> security issue it was supposed to address and the warning is likely to
> >> cause unnecessary alarm to users with unusual yet legitimate setups.
> >
> > IIRC, the point was that some apps expect $HOME to be owned by the
> > user in order to operate correctly.
> 
> Originally at least it was supposed to address this:
> 
> http://www.cygwin.com/ml/cygwin-developers/2010-09/msg00007.html
> 
> The $HOME warning doesn't address this because for example a
> maliciously prepared /home/$USER/.bash_profile would still get
> sourced.
> 
> I can't remember other reasons.

OK. I'll drop it then.

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?)
  2011-03-18 14:17   ` David Sastre
  2011-03-18 14:31     ` Andy Koppe
  2011-03-18 16:20     ` Nellis, Kenneth
@ 2011-03-20  9:19     ` Cyrille Lefevre
  2011-03-20 19:14       ` Cyrille Lefevre
  2 siblings, 1 reply; 22+ messages in thread
From: Cyrille Lefevre @ 2011-03-20  9:19 UTC (permalink / raw)
  To: cygwin


Le 18/03/2011 14:46, David Sastre a écrit :

>> [ -e "${p}" ]&&  IFS=',' read -r PRINTER dummy<  "${p}"
>
> Works in bash, posh, mksh and zsh, but fails (at least for me) in
> dash.

regarding SUSv3, read is not a special builtin, so, should work under 
every shell, if that fails under dash, it should be fixed.

Regards,

Cyrille Lefevre
-- 
mailto:Cyrille.Lefevre-lists@laposte.net



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?)
  2011-03-20  9:19     ` IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?) Cyrille Lefevre
@ 2011-03-20 19:14       ` Cyrille Lefevre
  2011-03-21 14:34         ` Eric Blake
  0 siblings, 1 reply; 22+ messages in thread
From: Cyrille Lefevre @ 2011-03-20 19:14 UTC (permalink / raw)
  To: cygwin


Le 19/03/2011 23:34, Cyrille Lefevre a écrit :
>
>
> Le 18/03/2011 14:46, David Sastre a écrit :
>
>>> [ -e "${p}" ]&& IFS=',' read -r PRINTER dummy< "${p}"
>>
>> Works in bash, posh, mksh and zsh, but fails (at least for me) in
>> dash.
>
> regarding SUSv3, read is not a special builtin, so, should work under
> every shell, if that fails under dash, it should be fixed.

fixed in git depot as of :

2010-05-27 	Herbert Xu	[VAR] Do not poplocalvars prematurely on regular 
utilitie
http://git.kernel.org/?p=utils/dash/dash.git;a=snapshot;h=1d806ac1fbafb867f6252e184e1be05c0829ab71;sf=tgz

$ echo a b,c | ./dash -c 'IFS=, read a b; echo $a'
a b

however, there are a lot of change on 2010-05-27/28, the last one is :
http://git.kernel.org/?p=utils/dash/dash.git;a=snapshot;h=0cda2e1f8d8222fa497f808b54a2146d60e304f5;sf=tgz

how about to update dash from git since the last release is almost one 
year old ?

Regards,

Cyrille Lefevre
-- 
mailto:Cyrille.Lefevre-lists@laposte.net



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?)
  2011-03-20 19:14       ` Cyrille Lefevre
@ 2011-03-21 14:34         ` Eric Blake
  0 siblings, 0 replies; 22+ messages in thread
From: Eric Blake @ 2011-03-21 14:34 UTC (permalink / raw)
  To: Cyrille Lefevre; +Cc: cygwin

[-- Attachment #1: Type: text/plain, Size: 538 bytes --]

On 03/20/2011 08:54 AM, Cyrille Lefevre wrote:
> fixed in git depot as of :
> 
> 2010-05-27     Herbert Xu    [VAR] Do not poplocalvars prematurely on
> regular utilitie
> http://git.kernel.org/?p=utils/dash/dash.git;a=snapshot;h=1d806ac1fbafb867f6252e184e1be05c0829ab71;sf=tgz

> how about to update dash from git since the last release is almost one
> year old ?

I'll work on that soon.  Thanks for the heads-up.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: Problems with the new base-files-4.0-5?
  2011-03-17 22:11       ` David Sastre
@ 2011-03-18 12:45         ` Nellis, Kenneth
  0 siblings, 0 replies; 22+ messages in thread
From: Nellis, Kenneth @ 2011-03-18 12:45 UTC (permalink / raw)
  To: cygwin

> From: David Sastre
> Please test if
> 
> [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
> 
> works as expected.

No, it doesn't work, probably due to bash subshell or something,
as separating the final assignment from the command line *does*
work:

$ [ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}
$ echo $PRINTER
\\tmsdc2\TMSEngineering,winspool,Ne02:
$ PRINTER=${PRINTER%%,*}
$ echo $PRINTER
\\tmsdc2\TMSEngineering
$

--Ken Nellis

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 22:07     ` Nellis, Kenneth
@ 2011-03-17 22:11       ` David Sastre
  2011-03-18 12:45         ` Nellis, Kenneth
  0 siblings, 1 reply; 22+ messages in thread
From: David Sastre @ 2011-03-17 22:11 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]

On Thu, Mar 17, 2011 at 04:10:27PM -0500, Nellis, Kenneth wrote:
> > From: Eric Blake
> > On 03/17/2011 12:59 PM, Angelo Graziosi wrote:
> > > Il 17/03/2011 19.00, Angelo Graziosi ha scritto:
> > >> I have just updated Cygwin, and now starting a console (Cygwin.bat
> > or
> > >> MinTTY) prints:
> > >>
> > >> -bash: ${p}: ambiguous redirect
> > >>
> > >> and PRINTER variable isn't set.
> > >>
> > >> Reverting to base-files-4.0-4 works just fine and PRINTER is set
> > >> correctly to my default printer.
> > >>
> > >> In 4.0-5 it seems something is broken in /etc/profile.
> 
> I see the same thing.
> 
> > > Perhaps you need this:
> > >
> > > - ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
> > > + ([[ -e ${p} ]] && read -r PRINTER < "${p}") &&
> > PRINTER=${PRINTER%%,*}

Please test if

[ -e "${p}" ] && read -r PRINTER < "${p}" && PRINTER=${PRINTER%%,*}

works as expected. 

> > /etc/profile is using [[ ]]?  Bad.  That's not required by POSIX, and
> > will break for anyone who logs in with a shell that doesn't understand
> > it (for example, dash or posh).  Bashisms should not appear in
> > /etc/profile.
> 
> Seems there are several instances of this:
> 
> $ grep '\[\[' /etc/profile
> ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
> if [[ -n ${BASH_VERSION} ]]; then
>   [[ -f "/etc/bash.bashrc" ]] && . "/etc/bash.bashrc"
> elif [[ -n ${KSH_VERSION} ]]; then
> elif [[ -n ${ZSH_VERSION} ]]; then
> $

Corrected. Included in the next release.

> Is it reasonable to presume a quick turnaround on a fix?

Yes. It will be available ASAP.

-- 
Huella de clave primaria: 0FDA C36F F110 54F4 D42B  D0EB 617D 396C 448B 31EB

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: Problems with the new base-files-4.0-5?
  2011-03-17 19:39   ` Eric Blake
  2011-03-17 19:40     ` Charles Wilson
@ 2011-03-17 22:07     ` Nellis, Kenneth
  2011-03-17 22:11       ` David Sastre
  1 sibling, 1 reply; 22+ messages in thread
From: Nellis, Kenneth @ 2011-03-17 22:07 UTC (permalink / raw)
  To: cygwin

> From: Eric Blake
> On 03/17/2011 12:59 PM, Angelo Graziosi wrote:
> > Il 17/03/2011 19.00, Angelo Graziosi ha scritto:
> >> I have just updated Cygwin, and now starting a console (Cygwin.bat
> or
> >> MinTTY) prints:
> >>
> >> -bash: ${p}: ambiguous redirect
> >>
> >> and PRINTER variable isn't set.
> >>
> >> Reverting to base-files-4.0-4 works just fine and PRINTER is set
> >> correctly to my default printer.
> >>
> >> In 4.0-5 it seems something is broken in /etc/profile.

I see the same thing.

> > Perhaps you need this:
> >
> > - ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
> > + ([[ -e ${p} ]] && read -r PRINTER < "${p}") &&
> PRINTER=${PRINTER%%,*}
> 
> /etc/profile is using [[ ]]?  Bad.  That's not required by POSIX, and
> will break for anyone who logs in with a shell that doesn't understand
> it (for example, dash or posh).  Bashisms should not appear in
> /etc/profile.

Seems there are several instances of this:

$ grep '\[\[' /etc/profile
([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
if [[ -n ${BASH_VERSION} ]]; then
  [[ -f "/etc/bash.bashrc" ]] && . "/etc/bash.bashrc"
elif [[ -n ${KSH_VERSION} ]]; then
elif [[ -n ${ZSH_VERSION} ]]; then
$

Is it reasonable to presume a quick turnaround on a fix?

--Ken Nellis





^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 19:39   ` Eric Blake
@ 2011-03-17 19:40     ` Charles Wilson
  2011-03-17 22:07     ` Nellis, Kenneth
  1 sibling, 0 replies; 22+ messages in thread
From: Charles Wilson @ 2011-03-17 19:40 UTC (permalink / raw)
  To: cygwin

On 3/17/2011 3:21 PM, Eric Blake wrote:
> On 03/17/2011 12:59 PM, Angelo Graziosi wrote:
>> Perhaps you need this:
>>
>> - ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
>> + ([[ -e ${p} ]] && read -r PRINTER < "${p}") && PRINTER=${PRINTER%%,*}
> 
> /etc/profile is using [[ ]]?  Bad.  That's not required by POSIX, and
> will break for anyone who logs in with a shell that doesn't understand
> it (for example, dash or posh).  Bashisms should not appear in /etc/profile.

Yep. This is /etc/profile which is used by all POSIX shells, not just
bash.  Now, if we were talking about ~/.bash_profile or some mythical
/etc/bash_profile [1], that'd be different.

[1] bash doesn't actually use any file by this name

Try running this

$ dash -li

(oddly, posh -li doesn't report any errors...)

--
Chuck



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 19:15 ` Angelo Graziosi
  2011-03-17 19:16   ` Christopher Faylor
@ 2011-03-17 19:39   ` Eric Blake
  2011-03-17 19:40     ` Charles Wilson
  2011-03-17 22:07     ` Nellis, Kenneth
  1 sibling, 2 replies; 22+ messages in thread
From: Eric Blake @ 2011-03-17 19:39 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 963 bytes --]

On 03/17/2011 12:59 PM, Angelo Graziosi wrote:
> Il 17/03/2011 19.00, Angelo Graziosi ha scritto:
>> I have just updated Cygwin, and now starting a console (Cygwin.bat or
>> MinTTY) prints:
>>
>> -bash: ${p}: ambiguous redirect
>>
>> and PRINTER variable isn't set.
>>
>> Reverting to base-files-4.0-4 works just fine and PRINTER is set
>> correctly to my default printer.
>>
>> In 4.0-5 it seems something is broken in /etc/profile.
> 
> Perhaps you need this:
> 
> - ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
> + ([[ -e ${p} ]] && read -r PRINTER < "${p}") && PRINTER=${PRINTER%%,*}

/etc/profile is using [[ ]]?  Bad.  That's not required by POSIX, and
will break for anyone who logs in with a shell that doesn't understand
it (for example, dash or posh).  Bashisms should not appear in /etc/profile.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 19:15 ` Angelo Graziosi
@ 2011-03-17 19:16   ` Christopher Faylor
  2011-03-17 19:39   ` Eric Blake
  1 sibling, 0 replies; 22+ messages in thread
From: Christopher Faylor @ 2011-03-17 19:16 UTC (permalink / raw)
  To: cygwin

On Thu, Mar 17, 2011 at 07:59:11PM +0100, Angelo Graziosi wrote:
>Il 17/03/2011 19.00, Angelo Graziosi ha scritto:
>> I have just updated Cygwin, and now starting a console (Cygwin.bat or
>> MinTTY) prints:
>>
>> -bash: ${p}: ambiguous redirect
>>
>> and PRINTER variable isn't set.
>>
>> Reverting to base-files-4.0-4 works just fine and PRINTER is set
>> correctly to my default printer.
>>
>> In 4.0-5 it seems something is broken in /etc/profile.
>
>Perhaps you need this:
>
>- ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
>+ ([[ -e ${p} ]] && read -r PRINTER < "${p}") && PRINTER=${PRINTER%%,*}

Or even,
+ ([[ -e "${p}" ]] && read -r PRINTER < "${p}") && PRINTER=${PRINTER%%,*}

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Problems with the new base-files-4.0-5?
  2011-03-17 18:22 Problems with the new base-files-4.0-5? Angelo Graziosi
@ 2011-03-17 19:15 ` Angelo Graziosi
  2011-03-17 19:16   ` Christopher Faylor
  2011-03-17 19:39   ` Eric Blake
  0 siblings, 2 replies; 22+ messages in thread
From: Angelo Graziosi @ 2011-03-17 19:15 UTC (permalink / raw)
  To: Cygwin

Il 17/03/2011 19.00, Angelo Graziosi ha scritto:
> I have just updated Cygwin, and now starting a console (Cygwin.bat or
> MinTTY) prints:
>
> -bash: ${p}: ambiguous redirect
>
> and PRINTER variable isn't set.
>
> Reverting to base-files-4.0-4 works just fine and PRINTER is set
> correctly to my default printer.
>
> In 4.0-5 it seems something is broken in /etc/profile.

Perhaps you need this:

- ([[ -e ${p} ]] && read -r PRINTER < ${p}) && PRINTER=${PRINTER%%,*}
+ ([[ -e ${p} ]] && read -r PRINTER < "${p}") && PRINTER=${PRINTER%%,*}

> Ciao,
> Angelo.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Problems with the new base-files-4.0-5?
@ 2011-03-17 18:22 Angelo Graziosi
  2011-03-17 19:15 ` Angelo Graziosi
  0 siblings, 1 reply; 22+ messages in thread
From: Angelo Graziosi @ 2011-03-17 18:22 UTC (permalink / raw)
  To: Cygwin

I have just updated Cygwin, and now starting a console (Cygwin.bat or 
MinTTY) prints:

-bash: ${p}: ambiguous redirect

and PRINTER variable isn't set.

Reverting to base-files-4.0-4 works just fine and PRINTER is set 
correctly to my default printer.

In 4.0-5 it seems something is broken in /etc/profile.

Ciao,
Angelo.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2011-03-21 14:31 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-17 23:07 Problems with the new base-files-4.0-5? Angelo Graziosi
2011-03-17 23:41 ` David Sastre
2011-03-17 23:46   ` Christopher Faylor
2011-03-18  2:51 ` Cyrille Lefevre
2011-03-18 14:17   ` David Sastre
2011-03-18 14:31     ` Andy Koppe
2011-03-18 16:28       ` David Sastre
2011-03-18 16:43         ` Andy Koppe
2011-03-18 18:02           ` David Sastre
2011-03-18 16:20     ` Nellis, Kenneth
2011-03-18 16:41       ` David Sastre
2011-03-20  9:19     ` IFS/read dash bug (was Re: Problems with the new base-files-4.0-5?) Cyrille Lefevre
2011-03-20 19:14       ` Cyrille Lefevre
2011-03-21 14:34         ` Eric Blake
  -- strict thread matches above, loose matches on Subject: below --
2011-03-17 18:22 Problems with the new base-files-4.0-5? Angelo Graziosi
2011-03-17 19:15 ` Angelo Graziosi
2011-03-17 19:16   ` Christopher Faylor
2011-03-17 19:39   ` Eric Blake
2011-03-17 19:40     ` Charles Wilson
2011-03-17 22:07     ` Nellis, Kenneth
2011-03-17 22:11       ` David Sastre
2011-03-18 12:45         ` Nellis, Kenneth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).