Re: Bash readline remap ESC insert/command mode key
On Sat, Jan 21, 2012 at 09:17:32PM -0500, Chet Ramey wrote: I could look at putting in some sort of inter-character timeout, but I don't know yet how well the code structure lends itself to that. Ditto. VIM times-out after a (less then) 1 second pause after nothing else is typed. Readline doesn't time-out after the initial detection. To me, this would be a simple code snippet insertion, but I wouldn't know where to begin. :-/ -- Roger http://rogerx.freeshell.org/
test if shell is interactive
Simple script a.sh: #!/bin/bash echo PS1: $PS1 Variable $PS1 is present: # echo $PS1 \[\033[01;32m\]$USER@\h \[\033[00m\]\A \[\033[01;34m\]\w\[\033[00m\]\$ Variable $PS1 is environment: # env | grep PS1 PS1=\[\033[01;32m\]$USER@\h \[\033[00m\]\A \[\033[01;34m\]\w\[\033[00m\]\$ Executing script: # ./a.sh PS1: Variable PS1 is empty in child process. Whether the enviroment variable should not be copied to the child process? Am I doing something wrong? Popular methods to test if shell is interactive or not don't work for me: 1. case $- in *i*)echo This shell is interactive ;; *)echo This shell is not interactive ;; esac 2. if [ -z $PS1 ]; then echo This shell is not interactive else echo This shell is interactive fi -- View this message in context: http://old.nabble.com/test-if-shell-is-interactive-tp33183345p33183345.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: test if shell is interactive
On Sun, Jan 22, 2012 at 9:39 AM, tapczan tapc...@unx.pl wrote: 1. case $- in *i*) echo This shell is interactive ;; *) echo This shell is not interactive ;; esac This is the correct way to test. What makes you say it's not working for you?
Re: test if shell is interactive
DJ Mills wrote: This is the correct way to test. What makes you say it's not working for you? Variable $- value: # echo $- himBH character 'i' meens is interactive, ok. I have script a.sh: #!/bin/bash echo $- Execution: # ./a.sh hB There is no 'i' so the session is non-interactive? It was invoked from interactive. Am I missing something? I tested on vanilla debian 6.0, ubuntu 11.10 - effect is the same. -- View this message in context: http://old.nabble.com/test-if-shell-is-interactive-tp33183345p33184499.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: test if shell is interactive
tapczan wrote: #!/bin/bash echo $- Execution: # ./a.sh hB There is no 'i' so the session is non-interactive? It was invoked from interactive. Am I missing something? Shell scripts are not interactive. So what you are seeing above is correct. Bob
Re: test if shell is interactive
Bob Proulx wrote: Shell scripts are not interactive. So what you are seeing above is correct. So, is there any way to test if script (a.sh) was invoked from interactive session (human) or not (e.g. from cron)? -- View this message in context: http://old.nabble.com/test-if-shell-is-interactive-tp33183345p33184711.html Sent from the Gnu - Bash mailing list archive at Nabble.com.
Re: test if shell is interactive
On Sun, 22 Jan 2012, tapczan wrote: Bob Proulx wrote: Shell scripts are not interactive. So what you are seeing above is correct. So, is there any way to test if script (a.sh) was invoked from interactive session (human) or not (e.g. from cron)? Test whether it is attached to a tty: if [ -t 1 ] then echo Interactive else echo Not interactive fi -- Chris F.A. Johnson, http://cfajohnson.com/ Author: Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
Re: test if shell is interactive
tapczan wrote: Bob Proulx wrote: Shell scripts are not interactive. So what you are seeing above is correct. So, is there any way to test if script (a.sh) was invoked from interactive session (human) or not (e.g. from cron)? I usually check if the standard input file descriptor is attached to a tty device or not. #!/bin/sh if [ -t 0 ]; then echo has a tty else echo does not have a tty fi exit 0 Or something like: $ test -t 0 echo yes tty || echo no tty Note: This discussion thread is much better suited for help-bash since it isn't talking about a bug in bash. In the future if you are just asking questions that would be the better list to send them to. Bob
Re: Bash readline remap ESC insert/command mode key
On 1/22/12 7:35 AM, Roger wrote: On Sat, Jan 21, 2012 at 09:17:32PM -0500, Chet Ramey wrote: I could look at putting in some sort of inter-character timeout, but I don't know yet how well the code structure lends itself to that. Pretty easily, as it turns out. The attached patch adds a half-second timeout to the key sequence code. Please let me know whether or not it works for you. 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/ *** ../bash-4.2-patched/lib/readline/readline.c 2010-07-25 17:07:40.0 -0400 --- lib/readline/readline.c 2012-01-22 16:47:45.0 -0500 *** *** 856,859 --- 891,900 #endif + /* Tentative inter-character timeout for potential multi-key + sequences? If no input within timeout, abort sequence and + act as if we got non-matching input. */ + if (_rl_input_queued (50) == 0) + return (_rl_subseq_result (-2, map, key, got_subseq)); + newkey = _rl_subseq_getchar (key); if (newkey 0)
Re: Cross compile crapout
On Sat, 2012-01-21 at 19:45 -0500, Chet Ramey wrote: On 1/21/12 11:13 AM, Jonathan Andrews wrote: I found the fix here, but it would be nice if it could work its way into the source for the next release. http://lists.gnu.org/archive/html/bug-bash/2011-09/msg00039.html This is patch 18 to bash-4.2. Ooops! I had not noticed it even had patches, sorry. It might be worth mentioning the possible existence of patches in README or INSTALL. As is normal for projects I had limited time so I just googled bash src and downloaded the newest. I needed a statically linked bash for testing an arm board. I did not expect it to be nearly 3MB though ! It surprises me that a statically linked bash is bigger than the entire busybox binary i've compiled, or my kernel image for that matter. Is this bloat gcc, some failing of the linker or bash itself? Thanks, Jon
[bug] Bash translates $var into $var for exported functions.
Hello, In the case of exported functions, Bash interprets a copy descriptor followed by an expansion as the synonym for , resulting in the output going to a file named as the value of the FD it's given. This only applies to $var and not $var. I've tested various quoting, Is there some way around this? Gist over here if it's easier to read: https://gist.github.com/1661392 TESTCASE (Overwrites the file named 3 in CWD): #!/usr/bin/env bash set -x f() { echo 'hi' } ${1} { f 3; cat; } '' 3/dev/stdin export -f f export -pf PS4='* ' BASH_XTRACEFD=4 bash -xc 'f 3; cat' '' 3/dev/stdin 42 [[ -f 3 ]] cat ./3 END TESTCASE OUTPUT: ~ $ rm 3; ./exbug + f 3 + echo hi + cat hi + export -f f + export -pf f () { echo 'hi' } ${1} declare -fx f * PS4='* ' * BASH_XTRACEFD=4 + bash -xc 'f 3; cat' * f 3 * echo hi * cat + [[ -f 3 ]] + cat ./3 hi END OUTPUT Bash v. 4.2 w/ patchset 20 on Gentoo Linux amd64. -- Dan Douglas signature.asc Description: This is a digitally signed message part.