Re: Non Incremental Nature of Custom Completion

2011-12-07 Thread Chet Ramey
On 12/6/11 12:04 PM, Bastien Dejean wrote:
 Hi,
 
 I've made a custom completion function for one of my tools:
 
 https://github.com/baskerville/owl
 
 And I'd like `compgen -f` to behave like the default bash filename
 completion, but it doesn't: for example, if I type `f` and if the only
 file starting with `f` in the current directory is a directory named
 `foo`, then, if I press `Tab`, I'll get `foo `, I'd like to get `foo/`
 instead. 

`compgen' only generates possible completions.  It's readline's job to
display them and append the appropriate characters.  You tell readline
how to behave when you install the completion with `complete'.  For
instance, `complete -o filenames ...' will tell readline that the
completion spec generates filenames, so the resulting words should be
quoted, if necessary, checked whether they are directories, and so on.

If you want to change these options on the fly, while a completion
function is executing, you can use `compopt' to set or unset them.

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 silently ignores additional arguments for cd

2011-12-07 Thread hanzl
Configuration Information [Automatically generated, do not change]:
Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2
uname output: Linux mepi 2.6.22-1-mepis-smp #1 SMP PREEMPT Sun Nov 11 15:54:46 
EST 2007 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.2
Patch Level: 0
Release Status: release

Description:
cd silently ignores additional arguments
pwd, pushd and popd also do ignore additional arguments

This seemes to be a long standing behavior, it is the same in bash 
3.1.17.

Problem is also described here: 
http://old.nabble.com/cd-with-multiple-arguments--td30418151.html

This bug is mostly benign, however missing newline at the end of a cd 
command leads to
silent skip of the following command line. Error report would help here.

Repeat-By:
cd xxx yyy

No error is reported for yyy.

Fix:
Make bash to report error for superfluous arguments for cd, pwd, pushd 
and popd.
Alternatively, describe current behavior in bash man page (and 
preferably
explain - maybe it is required for compatibility with some historical 
shell?)



Re: Bash git repository on savannah

2011-12-07 Thread Chet Ramey
On 11/23/11 11:23 PM, Chet Ramey wrote:
 I spent a little while messing around with git over the past couple of
 days, and ended up updating the bash git repository on savannah
 (http://git.savannah.gnu.org/cgit/bash.git to browse the sources).
 Bash-4.2 patch 20 is the head of the tree, and there's a branch
 containing the `direxpand' patches that I've posted here.  Each
 bash-4.2 patch is in there as a separate commit.

There is now a `devel' branch on the git tree, starting with bash-2.05b
and bash-3.0-alpha.  There are regular (mostly weekly) snapshot updates,
each a separate commit to that branch.  I'm currently up to bash-4.0,
which represents about five years of work starting in January 2004, and
I'm updating as frequently as I have the chance.  Each intermediate
release (e.g., bash-3.2-beta) for which I have a copy is a separate
commit; the milestone releases I don't have are marked with tags to
the appropriate weekly snapshot commit.

Take a look if you're interested and let me know what you think.

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: bash silently ignores additional arguments for cd

2011-12-07 Thread Eric Blake
On 12/07/2011 06:21 AM, ha...@noel.feld.cvut.cz wrote:
 Description:
   cd silently ignores additional arguments
   pwd, pushd and popd also do ignore additional arguments
 
   This seemes to be a long standing behavior, it is the same in bash 
 3.1.17.
 
   Problem is also described here: 
 http://old.nabble.com/cd-with-multiple-arguments--td30418151.html
 
   This bug is mostly benign, however missing newline at the end of a cd 
 command leads to
   silent skip of the following command line. Error report would help here.
 
 Repeat-By:
   cd xxx yyy
 
   No error is reported for yyy.
 
 Fix:
   Make bash to report error for superfluous arguments for cd, pwd, pushd 
 and popd.
   Alternatively, describe current behavior in bash man page (and 
 preferably
   explain - maybe it is required for compatibility with some historical 
 shell?)

Or even nicer, behave like zsh, and treat
 cd xxx yyy
like this (written assuming extglob syntax)
 cd xxx+($' \t')yyy

POSIX does not require 'cd xxx yyy' to fail, it only requires that
portable applications pass at most one argument to cd, such that passing
more than one argument triggers unspecified behavior.  We might as well
make that behavior intuitive.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: bash silently ignores additional arguments for cd

2011-12-07 Thread Chet Ramey
On 12/7/11 8:21 AM, ha...@noel.feld.cvut.cz wrote:

 Bash Version: 4.2
 Patch Level: 0
 Release Status: release
 
 Description:
   cd silently ignores additional arguments
   pwd, pushd and popd also do ignore additional arguments
 
   This seemes to be a long standing behavior, it is the same in bash 
 3.1.17.
 
   Problem is also described here: 
 http://old.nabble.com/cd-with-multiple-arguments--td30418151.html
 
   This bug is mostly benign, however missing newline at the end of a cd 
 command leads to
   silent skip of the following command line. Error report would help here.

It's an interesting question.  There's a question about whether or not this
behavior, which is more-or-less traditional, is a bug at all.  While the
Bourne shells from v7 through SVR4.2 don't complain about multiple
arguments, many other Posix-style shells do.

My feeling on the matter is that this kind of behavior should be possible,
but it's not necessary to have it be the default.  It seems like it's a
relatively minor error case, and it's this kind of thing that motivated
the ability to have shell functions override shell builtins in the first
place.

For instance, the function replacement for cd that appears in
examples/kshenv in the bash distribution does what you want and more.

I agree with the suggestion in the referenced message thread about the
usefulness of a library of bash functions.  That was the original intent
of the examples/ subdirectory, but I hsven't solicited any contributions
for that in some time.  (Consider this a solicitation, if you're so
inclined.)

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: bash silently ignores additional arguments for cd

2011-12-07 Thread Vaclav Hanzl
(Sorry, this is reply to Chet Ramey, but I just subscribed to the list
and web interface does not contain enough info to get threads right)

 It's an interesting question.  There's a question about whether or not this
 behavior, which is more-or-less traditional, is a bug at all.

I would certainly be satisfied by just mentioning this 'feature' in
the bash man page. People would not be so surprised as I was, and it
would save time to those who will consider sending a bug report in the
future. Downloading and compiling latest bash was easy :-), but we
still can save this exercise to others.

Regards,

Vaclav Hanzl