Re: ulimit and ssh?

2010-01-08 Thread peter360

Thanks Bob.  All the explanation were very helpful.  Now I feel I have a good
understanding of this little peculiarity of ssh.   I agree with you that
avoiding quoting altogether is simpler.   But I am curious guy and learning
for the sake of better understanding is also important to me.



Bob Proulx wrote:
> 
> peter360 wrote:
>> Thanks Adreas.  That was what I suspected in my reply to Bob.  But Bob
>> disagreed.   Looks like there were some confusion about this feature even
>> among experts.  Seems another reason to deprecate the feature.
> 
> I don't think anything I said disagreed with what Andreas said.  It is
> just confusing you since we are talking about different points in the
> process.  What does the local shell do, what does the ssh do, what
> does the remote shell do, what is the end-to-end effect and so forth.
> All three processes are handling the arguments and each has an affect
> at different points in the timeline.  I was talking end-to-end
> (shell-ssh-shell) and Andreas was talking about ssh.
> 
> And by the way but this feature can't really be changed or it would
> break twenty years or so of scripts which rely upon the existing
> behavior.
> 
> Greg Wooledge wrote:
>> imadev:~$ $HOME/bin/args 'ulimit -a'
>> 1 args: 'ulimit -a'
>> imadev:~$ remsh localhost $HOME/bin/args 'ulimit -a'
>> 2 args: 'ulimit' '-a'
>> imadev:~$ ssh localhost $HOME/bin/args 'ulimit -a'
>> wool...@localhost's password:
>> 2 args: 'ulimit' '-a'
> 
> Nice!  It would also be illustrative to show what happens without any
> quoting and with quoting for two shell layers.
> 
>   $ $HOME/bin/show-args 'ulimit -a'
>   arg1: ulimit -a
> 
>   $ ssh -n localhost $HOME/bin/show-args ulimit -a
>   arg1: ulimit
>   arg2: -a
> 
>   $ ssh -n localhost $HOME/bin/show-args 'ulimit -a'
>   arg1: ulimit
>   arg2: -a
> 
>   $ ssh -n localhost $HOME/bin/show-args '"ulimit -a"'
>   arg1: ulimit -a
> 
> Since there are two shells splitting words in the end-to-end result
> then the effect is that you need to quote your arguments twice in
> order to have an argument containing whitespace in one argument by the
> time it has been processed through two shell's argument processing.
> 
> Without sufficient quoting you have this following case, which isn't
> what you want.  The bash shell on the remote end would not see args
> "-c" "ulimit -a" but would see "-a" as a separate
> 
>   $ ssh -n localhost $HOME/bin/show-args bash -c "ulimit -a"
>   arg1: bash
>   arg2: -c
>   arg3: ulimit
>   arg4: -a
> 
> That isn't what you want.  You need to quote the args twice.
> 
>   $ ssh -n localhost $HOME/bin/show-args 'bash -c "ulimit -a"'
>   arg1: bash
>   arg2: -c
>   arg3: ulimit -a
> 
> In the end you want something like this:
> 
>   $ ssh -n localhost 'bash -c "ulimit -a"'
>   core file size  (blocks, -c) 0
>   data seg size   (kbytes, -d) unlimited
>   scheduling priority (-e) 0
>   file size   (blocks, -f) unlimited
>   pending signals (-I) 8185
>   max locked memory   (kbytes, -l) 32
>   max memory size (kbytes, -m) unlimited
>   open files  (-n) 1024
>   pipe size(512 bytes, -p) 8
>   POSIX message queues (bytes, -q) 819200
>   real-time priority  (-r) 0
>   stack size  (kbytes, -s) 8192
>   cpu time   (seconds, -t) unlimited
>   max user processes  (-u) 8185
>   virtual memory  (kbytes, -v) unlimited
>   file locks  (-x) unlimited
> 
> However I think it is simpler to avoid the argument processing and
> instead using stdin to the shell.
> 
>   $ echo ulimit -a | ssh localhost bash
> 
> Isn't that simpler?
> 
> Bob
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ulimit-and-ssh--tp25262471p27086055.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





missing dep in lib/glob/Makefile.in

2010-01-08 Thread Mike Frysinger
lib/glob/glob.c uses shell.h and pathnames.h

--- bash-4.1/lib/glob/Makefile.in
+++ bash-4.1/lib/glob/Makefile.in
@@ -119,6 +119,11 @@
 mostlyclean: clean
-( cd doc && $(MAKE) $(MFLAGS) $@ )
 
+# Dependencies
+
+${BUILD_DIR}/pathnames.h: ${BUILD_DIR}/config.h ${BUILD_DIR}/Makefile Makefile
+   -( cd ${BUILD_DIR} && ${MAKE} ${MFLAGS} pathnames.h )
+
 ##
 #   #
 #  Dependencies for the object files which make up this library. #
@@ -136,7 +141,7 @@
 strmatch.o: $(BUILD_DIR)/config.h
 strmatch.o: $(BASHINCDIR)/stdc.h
 
-glob.o: $(BUILD_DIR)/config.h
+glob.o: $(BUILD_DIR)/config.h $(topdir)/shell.h $(BUILD_DIR)/pathnames.h
 glob.o: $(topdir)/bashtypes.h $(BASHINCDIR)/ansi_stdlib.h $(topdir)/bashansi.h
 glob.o: $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/memalloc.h
 glob.o: strmatch.h glob.h


signature.asc
Description: This is a digitally signed message part.


Re: ERR trap inheritance in command substitution

2010-01-08 Thread Chet Ramey
On 1/8/10 12:50 PM, Stefan Götz wrote:
> Hi!
> 
> It seems that in bash version 4.0.33(1)-release (i486-pc-linux-gnu) (from 
> Ubuntu
> 9.04), ERR traps are not inherited by functions that are called via command
> substitution. I expected inheritance to apply in this case since the
> documentation of 'set -E' promises inheritance of the ERR trap for subshell
> contexts. The script below illustrates this behavior as the trap action
> err_handler() is not called.
> 
> Is this behaviour intended? Even if so, I'd like to say that I would find ERR
> trap inheritance for command substitution extremely useful :-)
> 
> Cheers,
>   Stefan
> 
> #!/bin/bash
> 
> err_handler() {
>   echo "THERE WAS AN ERROR"
> }
> 
> set -E
> trap 'err_handler' ERR
> 
> myfunc() {
>   false # fails to cause an ERR trap
>   true
> }
> 
> FOO=$(myfunc)
> exit 0

How does this script demonstrate that err_handler is not called?  The
command substitution swallows all the output, and you never look at
the results.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: Told to report this bug here.

2010-01-08 Thread Chet Ramey
On 1/8/10 3:50 PM, Frank J. R. Hanstick wrote:
> Hello,
> I downloaded the bash-80 file from Apple and encountered this
> configuration error:

Aside from the fact that the bash-80 tar file available from Apple is
packaged by Apple, this doesn't exactly look like a bash problem:


> configure:15416: checking wchar.h usability
> configure:15428: gcc -c -arch ppc -g -Os -pipe -no-cpp-precomp
> -mdynamic-no-pic -DM_UNIX -DSSH_SOURCE_BASHRC -isysroot
> /Developer/SDKs/MacOSX10.6.sdk/  conftest.c >&5
> In file included from
> /Developer/SDKs/MacOSX10.6.sdk//usr/include/wchar.h:111,
>  from conftest.c:264:
> /Developer/SDKs/MacOSX10.6.sdk//usr/include/stdarg.h:4:25: error:
> stdarg.h: No such file or directory

I build bash-3.x and 4.x on Mac OS X 10.5.x all the time (though not
specifying the 10.6 SDK).  You might consider downloading the official
distribution from gnu.org.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Told to report this bug here.

2010-01-08 Thread Frank J. R. Hanstick

Hello,
	I downloaded the bash-80 file from Apple and encountered this  
configuration error:


checking wchar.h usability... no
checking wchar.h presence... yes
configure: WARNING: wchar.h: present but cannot be compiled
		configure: WARNING: wchar.h: check for missing prerequisite  
headers?

configure: WARNING: wchar.h: see the Autoconf documentation
		configure: WARNING: wchar.h: section "Present But Cannot Be  
Compiled"

configure: WARNING: wchar.h: proceeding with the preprocessor's 
result
		configure: WARNING: wchar.h: in the future, the compiler will take  
precedence

configure: WARNING: ## --- ##
configure: WARNING: ## Report this to bug-bash@gnu.org ##
configure: WARNING: ## --- ##
checking for wchar.h... yes

when trying to build using the following command:

make SDKROOT="/Developer/SDKs/MacOSX10.6.sdk/" RC_ARCHS="ppc".

Extracted from config.log is the following:

configure:15416: checking wchar.h usability
configure:15428: gcc -c -arch ppc -g -Os -pipe -no-cpp-precomp - 
mdynamic-no-pic -DM_UNIX -DSSH_SOURCE_BASHRC -isysroot /Developer/SDKs/ 
MacOSX10.6.sdk/  conftest.c >&5
In file included from /Developer/SDKs/MacOSX10.6.sdk//usr/include/ 
wchar.h:111,

 from conftest.c:264:
/Developer/SDKs/MacOSX10.6.sdk//usr/include/stdarg.h:4:25: error:  
stdarg.h: No such file or directory

configure:15434: $? = 1
configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "bash"
| #define PACKAGE_TARNAME "bash"
| #define PACKAGE_VERSION "3.2-release"
| #define PACKAGE_STRING "bash 3.2-release"
| #define PACKAGE_BUGREPORT "bug-bash@gnu.org"
| #define ALIAS 1
| #define PUSHD_AND_POPD 1
| #define RESTRICTED_SHELL 1
| #define PROCESS_SUBSTITUTION 1
| #define PROMPT_STRING_DECODE 1
| #define SELECT_COMMAND 1
| #define HELP_BUILTIN 1
| #define ARRAY_VARS 1
| #define DPAREN_ARITHMETIC 1
| #define BRACE_EXPANSION 1
| #define COMMAND_TIMING 1
| #define EXTENDED_GLOB 1
| #define COND_COMMAND 1
| #define COND_REGEXP 1
| #define ARITH_FOR_COMMAND 1
| #define NETWORK_REDIRECTIONS 1
| #define PROGRAMMABLE_COMPLETION 1
| #define DEBUGGER 1
| #define MEMSCRAMBLE 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define READLINE 1
| #define HISTORY 1
| #define BANG_HISTORY 1
| #define _GNU_SOURCE 1
| #define HAVE_STRINGIZE 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1
| #define HAVE_STDLIB_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_GETPAGESIZE 1
| #define HAVE_MMAP 1
| #define INTDIV0_RAISES_SIGFPE 0
| #define HAVE_INTTYPES_H_WITH_UINTMAX 1
| #define HAVE_STDINT_H_WITH_UINTMAX 1
| #define HAVE_UNSIGNED_LONG_LONG 1
| #define HAVE_UINTMAX_T 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_NL_TYPES_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_FEOF_UNLOCKED 1
| #define HAVE_GETC_UNLOCKED 1
| #define HAVE_GETCWD 1
| #define HAVE_GETEGID 1
| #define HAVE_GETEUID 1
| #define HAVE_GETGID 1
| #define HAVE_GETUID 1
| #define HAVE_MUNMAP 1
| #define HAVE_PUTENV 1
| #define HAVE_SETENV 1
| #define HAVE_SETLOCALE 1
| #define HAVE_STPCPY 1
| #define HAVE_STRCASECMP 1
| #define HAVE_STRDUP 1
| #define HAVE_STRTOUL 1
| #define HAVE_TSEARCH 1
| #define HAVE_ICONV 1
| #define ICONV_CONST
| #define HAVE_LANGINFO_CODESET 1
| #define HAVE_LC_MESSAGES 1
| #define ENABLE_NLS 1
| #define HAVE_DIRENT_H 1
| #define TIME_WITH_SYS_TIME 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STDARG_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_LOCALE_H 1
| #define HAVE_TERMCAP_H 1
| #define HAVE_TERMIOS_H 1
| #define HAVE_DLFCN_H 1
| #define HAVE_STDDEF_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_NETDB_H 1
| #define HAVE_PWD_H 1
| #define HAVE_GRP_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_REGEX_H 1
| #define HAVE_SYS_SELECT_H 1
| #define HAVE_SYS_FILE_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYS_TIMES_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_NETINET_IN_H 1
| #define HAVE_ARPA_INET_H 1
| #define HAVE_ALLOCA_H 1
| #define HAVE_ALLOCA 1
| #define GETPGRP_VOID 1
| #define SETVBUF_REVERSED 1
| #define HAVE_VPRINTF 1
| #define HAVE_STRCOLL 1
| #define RETSIGTYPE void
| #define HAVE_WAIT3 1
| #define HAVE_ISINF_IN_LIBC 1
| #define HAVE_ISNAN_IN_LIBC 1
| #define HAVE_MKFIFO 1
|

ERR trap inheritance in command substitution

2010-01-08 Thread Stefan Götz
Hi!

It seems that in bash version 4.0.33(1)-release (i486-pc-linux-gnu) (from Ubuntu
9.04), ERR traps are not inherited by functions that are called via command
substitution. I expected inheritance to apply in this case since the
documentation of 'set -E' promises inheritance of the ERR trap for subshell
contexts. The script below illustrates this behavior as the trap action
err_handler() is not called.

Is this behaviour intended? Even if so, I'd like to say that I would find ERR
trap inheritance for command substitution extremely useful :-)

Cheers,
Stefan

#!/bin/bash

err_handler() {
  echo "THERE WAS AN ERROR"
}

set -E
trap 'err_handler' ERR

myfunc() {
  false # fails to cause an ERR trap
  true
}

FOO=$(myfunc)
exit 0




signature.asc
Description: OpenPGP digital signature