`builtin test -a foo` VS `builtin test ! -a foo`

2007-01-19 Thread Name withheld by request
In article <[EMAIL PROTECTED]>,
Name withheld by request <[EMAIL PROTECTED]> wrote:
>In bash the built-in 'test' command can act either as "and",
>or as a test for file existence:
>
>  ~ $ help test|grep -e -a
>  -a FILETrue if file exists.
>  EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
>
>I'm pretty sure this is not a bug, but please explain why:
>
>  ~ $ cd /tmp
>  /tmp $ date;uname -a
>  Sat Jan  6 09:09:19 CST 2007
>  Linux alex 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 athlon i386 
> GNU/Linux
>  /tmp $ touch foo
>  /tmp $ builtin test -a foo && echo hi
>  hi
>  /tmp $ builtin test ! -a foo && echo hi
>  hi
>  /tmp $

A bit more:
 
  /tmp $ rm -f foo; ls foo
  ls: foo: No such file or directory
  /tmp $ builtin test -a foo || echo ho
  ho
  /tmp $ builtin test ! -a foo || echo ho
  /tmp $
   
So 
  builtin test ! -a foo
is equivalent to
  true
ie it's not very useful, what is it I'm missing, why is this not a bug?

--
thanks
Tom

--
/tmp $ help test|egrep -A6 'Other operators'
Other operators:

-o OPTION  True if the shell option OPTION is enabled.
! EXPR True if expr is false.
EXPR1 -a EXPR2 True if both expr1 AND expr2 are true.
EXPR1 -o EXPR2 True if either expr1 OR expr2 is true.
--snip
/tmp $ touch foo;ls foo
foo
/tmp $ test -e foo;echo $?
0
/tmp $ test ! -e foo;echo $?
1
/tmp $ rm foo; ls foo
ls: foo: No such file or directory
/tmp $ test -e foo;echo $?
1
/tmp $ test ! -e foo;echo $?
0
/tmp $




___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


ssh localhost date # no startup files read: ~/{.bash_profile,.bash_login,.profile,.bashrc}

2005-06-10 Thread Name withheld by request
I posted this (see below/[should bash read ~/.bashrc when "ssh localhost date" 
runs?])
to the cygwin mailing list.  Was I correct? Any comments?
To get Cygwin's attention I need to prove they have a bug first..

  related thread: http://sources.redhat.com/ml/cygwin/2005-06/msg00306.html

vv
Below are two tests cases for "ssh localhost date". The Linux
test shows that ~/.bashrc is read. The Cygwin case shows none of
~/{.bash_profile,.bash_login,.profile,.bashrc} are read. Doesn't this
seem like a bug?

Tests today w/linux suggest, this bash man page snippet is important:

  Bash attempts to determine when it is being run  by  the  remote  shell
  daemon,  usually  rshd.  If bash determines it is being run by rshd, it
  reads and executes commands from ~/.bashrc, if that file exists and  is
  readable.

--
The tests:

  ~ $ uname -a
  CYGWIN_NT-5.0 argon 1.5.17(0.129/4/2) 2005-05-25 19:38 i686 unknown unknown 
Cygwin
  ~ $ grep $(id -un) /etc/passwd|awk -F: '{print $NF}'
  /bin/bash
  ~ $ seq 20|sed 's~^~## ~'|tee -a 
~/{.bash_profile,.bash_login,.profile,.bashrc}|tail -5
  ## 16
  ## 17
  ## 18
  ## 19
  ## 20
  ~ $ date
  Fri Jun 10 07:34:10 CDT 2005
  ~ $ date
  Fri Jun 10 07:37:48 CDT 2005
  ~ $ ssh localhost date
  Enter passphrase for key '/home/adm_tsr/.ssh/id_rsa':
  [EMAIL PROTECTED]'s password:
  Fri Jun 10 07:38:10 CDT 2005
  ~ $ ls -lurt ~/.[bp]*[^y] /etc/profile ##
  -rwxr-xr-x  1 adm_tsr Users 5070 Jun 10 07:29 /etc/profile*
  -rw-rw-r--  1 adm_tsr Users  222 Jun 10 07:34 /home/adm_tsr/.bash_profile
  -rw-rw-r--  1 adm_tsr Users  222 Jun 10 07:34 /home/adm_tsr/.bash_login
  -rw-rw-r--  1 adm_tsr Users  222 Jun 10 07:34 /home/adm_tsr/.profile
  -rw-rw-r--  1 adm_tsr Users  111 Jun 10 07:34 /home/adm_tsr/.bashrc

Linux test, notice ~/.bashrc is read:

  [EMAIL PROTECTED] rodmant]$ uname -a
  Linux alex 2.6.5-1.358 #1 Sat May 8 09:04:50 EDT 2004 i686 athlon i386 
GNU/Linux
  [EMAIL PROTECTED] rodmant]$ echo $SHELL
  /bin/bash
  [EMAIL PROTECTED] rodmant]$ grep rodmant /etc/passwd
  rodmant:x:502:502::/home/rodmant:/bin/bash
  [EMAIL PROTECTED] rodmant]$ seq 20|sed 's~^~## ~'|tee -a 
~/{.bash_profile,.bash_login,.profile,.bashrc}
  ## 1
  ## 2
  
  ## 19
  ## 20
  [EMAIL PROTECTED] rodmant]$ date
  Fri Jun 10 07:14:14 CDT 2005
  [EMAIL PROTECTED] rodmant]$ date
  Fri Jun 10 07:15:40 CDT 2005
  [EMAIL PROTECTED] rodmant]$ ssh localhost date
  [EMAIL PROTECTED]'s password:
  Fri Jun 10 07:16:11 CDT 2005
  [EMAIL PROTECTED] rodmant]$ ls -lurt ~/.[bp]*[^y] ##
  -rw-r--r--  1 rodmant rodmant  24 Mar 12 14:22 /home/rodmant/.bash_logout
  -rw-r--r--  1 rodmant rodmant 302 Jun 10 07:12 /home/rodmant/.bash_profile
  -rw-rw-r--  1 rodmant rodmant 111 Jun 10 07:14 /home/rodmant/.profile
  -rw-rw-r--  1 rodmant rodmant 111 Jun 10 07:14 /home/rodmant/.bash_login
  -rw-r--r--  1 rodmant rodmant 235 Jun 10 07:16 /home/rodmant/.bashrc
  [EMAIL PROTECTED] rodmant]$ ls -lu /etc/profile
  -rw-r--r--  1 root root 842 Jun 10 07:12 /etc/profile

On Tue 6/7/05 19:50 EDT Larry Hall wrote:
> At 04:10 PM 6/7/2005, you wrote:
> >
> >
> >I want to be able to run a noninteractive command like
> >
> >  ssh [EMAIL PROTECTED] somecommand
> >
> >where user "joedoe" has /bin/rbash in /etc/passwd for a shell.
> >
> >  How do I restrict the PATH that is seen for the above ssh session?
> >
> >I have tried changing and exporting PATH in ~joedoe/.bashrc but this
> >file is not read by prior to running "somecommand" above.
>
>
> This isn't a Cygwin-specific question so it's really off-topic for
> this list.  Of course, you can always use something like ~/.bash_login.
> See the bash man page for more details and what files get executed when.


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash