What exactly does "read -e" do? bind weirdnesses

2008-09-10 Thread rocky
The most recent bash docs say this about builtin function read with
option -e:

  Readline (@pxref{Command Line Editing}) is used to obtain the line.

Consider this little program:

PS4='-$LINENO: $? $ '
set -x
builtin bind '"\C-x\C-r": "bind completion"'
builtin bind -P
while read -e -p 'huh? ' line ; do
echo $line
done

when I run it and enter C-x-C-r (control x + control -r) when it
prompts for input here is what I see.

$ bind '"\C-x\C-r": "bind completion"'
$ bash ./rlbug.sh
-3: 0 $ builtin bind '"\C-x\C-r": "bind completion"'
-4: 1 $ builtin bind -P
-5: 1 $ read -e -p 'huh? ' line
huh?
-6: 0 $ declare -p line
declare -- line=""
-5: 0 $ read -e -p 'huh? ' line

There are a number of things going on, none of which can I find
answered in bashref.texi for bashd 4.0 alpha or 3.2.

First, I gather from the return code 1 that bind is failing inside the
script. All right, but no error message or warning is given? In an
interactive shell if I enter say "bind -Z" at least I will get a
message saying that the bind option is invalid. Inside a script though
nothing.

Second although -e allows for some sorts of readline editing there are
other kinds of readline expansions  that aren't getting run, In
particular C-x-C-r. Last and probably related, is the fact that C-x-C-
r isn't stored in variable line.  (Adding -r to "read" doesn't change
things.)

Ideally, it would be nice to have read routine that made use of the
full features of readline. Failing that, it would be nice to have
documented what features one gets with "read -e" and what features one
doesn't get.

Thanks


readline in read -e and dynamic-complete-history problems

2008-09-10 Thread lists-general
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: netbsdelf
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='netbsdelf' -DCONF_MACHTYPE='i386--netbsdelf' -DCONF_VENDOR='' 
-DLOCALEDIR='/usr/pkg/share/locale' -DPACKAGE='bash' -DSHELL  -DHAVE_CONFIG_H   
-I.  -I. -I./include -I./lib  
-DDEFAULT_PATH_VALUE=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin -I/usr/include 
-O2 -I/usr/include
uname output: NetBSD glacier.mikecappella.com 4.0_RC1 NetBSD 4.0_RC1 
(GENERIC.MP) #0: Sat Sep  1 15:50:48 PDT 2007  [EMAIL 
PROTECTED]:/home/builds/ab/netbsd-4-0-RC1/i386/200709011431Z-obj/home/builds/ab/netbsd-4-0-RC1/src/sys/arch/i386/compile/GENERIC.MP
 i386
Machine Type: i386--netbsdelf

Bash Version: 3.2
Patch Level: 33
Release Status: release

Description:
readline does not work correcly when used in read -e.  The following program 
shows
that read -e does not perform history completion correctly.

---
#!/bin/bash

set -o emacs
bind 'set show-all-if-ambiguous on'
bind 'set completion-ignore-case on'

#bind TAB:menu-complete
bind 'TAB:dynamic-complete-history'

urls="http://example.com http://sample.net http://example.us 
http://example.net";
for i in $urls ; do
history -s $i
done

echo $urls
compgen -W "$urls" http://sa
read -e -p "What? " arg1
---

previous-history and next-history works, but Tab completion only works for the
to the first instance.  And dynamic-complete-history or show-all-if-ambiguous
do not work.

Repeat-By:
Run the above program.  Hit Tab, note the partial completion to the first
ambiguous portion of the history.  Type any letter to from the urls list to
disambiguate and hit Tab again.  No additional completion occurs.

Also, try ^N or ^P to cycle through the history list.  Then backspace,
and Tab to complete.  Once again, Tab does not complete.




Re: Last modified files with owner / time / permissions

2008-09-10 Thread Jan Schampera

lexton wrote:

From what I read it is not good to use ls -la in the manner I use below. 
Could I run this by just using the find command with additional arguments? 
I still need to be able to print everything that the ls -la command gives me


GNU find has an -ls option IIRC, which produces output similar to ls -l. 
If that's not the case, you can always find ... -exec ls -ld {} \; or so.


J.




Last modified files with owner / time / permissions

2008-09-10 Thread lexton

Hi,

Below is a bash script that prints out the files that have been modified in
the last 5 days.

>From what I read it is not good to use ls -la in the manner I use below. 
Could I run this by just using the find command with additional arguments? 
I still need to be able to print everything that the ls -la command gives me

 - file owner and group
 - time stamp
 - permissions set



#!/bin/bash
# note run above line with -x for debug mode
PATH=/usr/bin:/bin; export PATH
{ # disk space left
  df -h;
  echo "";
  # last logins to system
  last;
  # last 5 days of file modications sorted by the 9th column ( file path )
  echo " Last 5 Days ";
  ls -lt $( find /websites/path/ -type f -mtime -5 ) | sort -k 9;
  echo " Full List ";
  ls -lt /websites/path/*;
}  | mail -s 'dev info' [EMAIL PROTECTED]
-- 
View this message in context: 
http://www.nabble.com/Last-modified-files-with-owner---time---permissions-tp19419342p19419342.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.