Re: TIMEOUT
On Sat, Apr 04, 2009 at 08:37:32AM -0300, Sergio Charpinel Jr. wrote: > So, first of all, I'm trying to find a way to combine TMOUT variable with > vlock. What's vlock? > I just found a way to do this in zhs. And if it is not possible, I > need to set TIMEOUT just for root, and it can't logout when root is using > screen. > I tried to do something, but I'm new in bash. My "script" didnt work. > > for f in $( ps ax ); do > if [ $f == "SCREEN" ]; then > export TMOUT=0 > fi > done OK, it looks like what you're trying to do is "set the TMOUT variable unless I am running inside screen". So the trick, then, is to determine whether you are running inside screen or not. I can think of two ways to do that: checking the "command" (argv[0]) of every parent process up through the chain to init; or looking for environment variables that would only be set when you're inside screen. The former is really, really bad (and your script looks like it might be attempting it, although it's doing it incorrectly). So let's look at the latter instead. A quick check through the screen(1) man page yields this: setenv [var [string]] Set the environment variable var to value string. If only var is spec- ified, the user will be prompted to enter a value. If no parameters are specified, the user will be prompted for both variable and value. The environment is inherited by all subsequently forked shells. So, what I would do is put one of these setenv commands into my ~/.screenrc and then check for whatever environment variable you've decided to set, when you're in .bashrc and deciding whether to set the TMOUT variable. Like so: ~/.screenrc: setenv I_AM_INSIDE_SCREEN 1 ~/.bashrc: if [[ ! $I_AM_INSIDE_SCREEN ]]; then TMOUT=300 fi If you need this to be done only for root, then you would do this in root's home directory and nobody else's.
Re: Brace expansion
> So... what gives??? I tried looking at info coreutils 'printf > invocation', and it does not even explicitly spell out what the %d > argument means, instead it just tells me "it's like the C printf, except > for these differences". I have never used C, and have no idea where to > look it up, so what good is that info page??? I'm trying to learn bash, > and have no desire to learn to program in C. The advantage of the C language printf is that it is familiar and well- specified. The entire rationale for implementing a command-line version is to leverage that familiarity. The best place to look up the specification is the Open Group standard: http://www.opengroup.org/onlinepubs/9699919799/utilities/printf.html#tag_20_94 and the description of the format string: http://www.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tag_05 (In this case, the answer is that numeric constants beginning with a `0' are interpreted as octal numbers.) Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://tiswww.tis.case.edu/~chet/
Re: checkwinsize doesn't work on Solaris due to missing #include for TIOCGWINSZ
Dan Price wrote: > [resubmitting, this doesn't seem to have gotten to bug-bash on my first > try a few weeks ago] > > Configuration Information [Automatically generated, do not change]: > Machine: i386 > OS: solaris2.11 > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' > +-DCONF_OSTYPE='solaris2.11' -DCONF_MACHTYPE='i386-pc-solaris2.11' > +-DCONF_VENDOR='pc' -DLOCALEDIR='/tmp/share/locale' -DPACKAGE='bash' -DSHELL > +-DHAVE_CONFIG_H -DSOLARIS -I. -I. -I./include -I./lib -g -O2 > uname output: SunOS xanadu 5.11 snv_108 i86pc i386 i86pc > Machine Type: i386-pc-solaris2.11 > Bash Version: 3.2 > Patch Level: 48 > Release Status: release > > Description: > > On Solaris/OpenSolaris platforms, I have discovered what I believe is a > bug in lib/sh/winsize.c. > > I discovered with a debugger that the get_new_window_size() function > has no effect on Solaris. In fact, here is what this file looks like if > you compile it: > > $ dis winsize.o > disassembly for winsize.o > section .text > get_new_window_size() > get_new_window_size: c3 ret > > That's it-- an empty function. The problem is that the appropriate header > file is not getting pulled in, in order to #define TIOCGWINSZ. > > As a result, even with 'shopt -s checkwinsize' set on Solaris, bash > does not check the win size on suspend of a program, or on program > exit. This is massively frustrating, and I know of several Solaris > users who have switched to zsh as a result of this bug. > > I have not tried bash 4.0, but looking at the source code, it appears > that the bug is present there as well. > > Repeat-By: > > Fix: > > I added an ifdef clause which looks to see if the HAVE_TERMIOS_H define > is set, after the #include of config.h. If it is, then I #include the > termios.h header file. This solves the problem, which I confirmed by > rebuilding and dis'ing the function. I also ran my recompiled bash > and confirmed that it now worked correctly. > > Thanks, I appreciate your time. I hope that I have adequately described > the problem; feel free to mail me if not. Try the attached patch and see if it fixes the problem. I can verify that the disassembly is very different on Solaris 8 and Solaris 10 after applying it. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ *** ../bash-4.0-patched/lib/sh/winsize.c2008-08-12 13:53:51.0 -0400 --- lib/sh/winsize.c2009-04-06 10:44:20.0 -0400 *** *** 31,44 #include ! #if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) ! /* For struct winsize on SCO */ ! /* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */ ! # if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH) ! #if defined (HAVE_SYS_STREAM_H) ! # include ! #endif #include ! # endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */ ! #endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */ #include --- 31,57 #include ! /* Try to find the definitions of `struct winsize' and TIOGCWINSZ */ ! ! #if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ) ! # include ! #endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ ! ! #if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) ! # include ! #endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ ! ! /* Not in either of the standard places, look around. */ ! #if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL) ! # if defined (HAVE_SYS_STREAM_H) ! #include ! # endif /* HAVE_SYS_STREAM_H */ ! # if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */ #include ! #define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */ ! # endif /* HAVE_SYS_PTEM_H */ ! # if defined (HAVE_SYS_PTE_H) /* ??? */ ! #include ! # endif /* HAVE_SYS_PTE_H */ ! #endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */ #include
Re: using mapfile is extreamly slow compared to oldfashinod ways to read files
Chet Ramey wrote: I'm sure there are efficiency improvements possible in the bash indexed array implementation, but sequentially accessing a data structure optimized for space and sparse arrays is never going to be as fast as a read-process loop, and that difference becomes more and more apparent the larger the array. Maybe bash should remember the last position to optimize accessing the next element? There are also always hash tables, which are a bit more expensive in memory use, but would provide faster lookups (and I /really/ hope you're using a hash - or at least some kind of tree - and not a list for named-element arrays!). -- Matthew Please do not quote my e-mail address unobfuscated in message bodies. -- Anyone who is capable of getting themselves made President should on no account be allowed to do the job. -- The Hitchhiker's Guide to the Galaxy (Douglas Adams)
Re: feature-request: brief syntax for $(type -p somecommand)
Mike Coleman wrote: It would be nice if there was some really brief syntax for $(type -p somecommand) p() { local what=$(type -p $1) shift 1 "$@" "$what" } p foobar ls -l p foobar strings ...etc also, 'complete -c p' -- Matthew Please do not quote my e-mail address unobfuscated in message bodies. -- Anyone who is capable of getting themselves made President should on no account be allowed to do the job. -- The Hitchhiker's Guide to the Galaxy (Douglas Adams)
Re: using mapfile is extreamly slow compared to oldfashinod ways to read files
Matthew Woehlke wrote: > Chet Ramey wrote: >> I'm sure there are efficiency improvements possible in the bash indexed >> array implementation, but sequentially accessing a data structure >> optimized for space and sparse arrays is never going to be as fast as >> a read-process loop, and that difference becomes more and more apparent >> the larger the array. > > Maybe bash should remember the last position to optimize accessing the > next element? I already took a couple of hours and implemented something like this. It will be in the next version. Sequential access performance is dramatically improved. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
set -x prejudiced; won't smell UTF-8 coffee
Gentlemen, -x's reporting should just pass the Chinese right back. $ set -x; export LC_ALL=$LANG; echo 中文 + export LC_ALL=zh_TW.UTF-8 + LC_ALL=zh_TW.UTF-8 + echo $'\344\270\255\346\226\207' 中文 Or OK, to be fair, even the ASCII should come back as octal escapes.
Re: dir*/** behavior
m...@ice.filescope.com wrote: Configuration Information [Automatically generated, do not change]: Machine: i686 OS: linux-gnu Compiler: i686-pc-linux-gnu-gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' -DSTANDARD_UTILS_PATH='/bin:/usr/bin:/sbin:/usr/sbin' -DSYS_BASHRC='/etc/bash/bashrc' -DSYS_BASH_LOGOUT='/etc/bash/bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC -march=pentium4 -O2 -pipe uname output: Linux ice.filescope.com 2.6.25.10 #5 PREEMPT Thu Nov 27 16:10:07 EST 2008 i686 Intel(R) Pentium(R) 4 CPU 1400MHz GenuineIntel GNU/Linux Machine Type: i686-pc-linux-gnu Bash Version: 4.0 Patch Level: 10 Release Status: release Description: (Note: I am in the root directory of the bash source code) [~/desktop/bash-4.0]$ ls -adl exampl*/** ls: cannot access examples/examples: No such file or directory ls: cannot access examples/examples/complete: No such file or directory ls: cannot access examples/examples/complete/bashcc-1.0.1.tar.gz: No such file or directory ls: cannot access examples/examples/complete/bash_completion: No such file or directory [...] The above-mentioned "ls -adl exampl*/**" command should work the same as "ls -adl examples/**"; however, as shown above, the behavior of the former command is wrong. The commands work properly in both KornShell and Z shell. --Matt Zyzik I get the same thing. Looks like a bug to me. - Ian Kelling
Re: set -x prejudiced; won't smell UTF-8 coffee
On Monday 06 April 2009 21:24:35 jida...@jidanni.org wrote: > Gentlemen, -x's reporting should just pass the Chinese right back. > $ set -x; export LC_ALL=$LANG; echo 中文 > + export LC_ALL=zh_TW.UTF-8 > + LC_ALL=zh_TW.UTF-8 > + echo $'\344\270\255\346\226\207' > 中文 i dont think that's UTF-8. unicode sure, but not UTF-8. at any rate, how exactly do you suggest differentiating between someone doing echo $'\344\270\255' and echo 中 ? a script that echos unprintable byte sequences that happen to form valid unicode sequences should not be displayed as such. > Or OK, to be fair, even the ASCII should come back as octal escapes. that's flat out illogical. printable ASCII is exactly the same in every character set (iso/unicode/etc..). -mike signature.asc Description: This is a digitally signed message part.
Re: set -x prejudiced; won't smell UTF-8 coffee
Mike Frysinger writes: > exactly do you suggest differentiating... I don't know. It's all truly over my head. All I know is "how are you going to 'market' this stuff in Asia?". I mean the US kids get to see all their -x feedback pretty, but Asians must see it garbled. I don't know. Some kind of set -o passthru mode, on by default?