Mikael Magnusson | 16 Aug 01:45

rfc patch, abort rm instead of only removing the * from the cmdline

It surprised me that this isn't already what happens, what do others think?
Imagine for example the typo
% rm -rf * /tmp
Before, even if you said no to the prompt, it will remove all your
files in /tmp.

--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2515,13 +2515,13 @@ execcmd(Estate state, int input, int output,
int how, int last1)
 	    next = nextnode(node);
 	    if (s[0] == Star && !s[1]) {
 		if (!checkrmall(pwd))
-		    uremnode(args, node);
+		    return;
 	    } else if (l > 2 && s[l - 2] == '/' && s[l - 1] == Star) {
 		char t = s[l - 2];

 		s[l - 2] = 0;
 		if (!checkrmall(s))
-		    uremnode(args, node);
+		    return;
 		s[l - 2] = t;
 	    }
 	}

--

-- 
Mikael Magnusson

(Continue reading)

Richard Hartmann | 8 Aug 03:31

A generic function/framework/mechanism for regular polling of data?

Hi all,

I was wondering if a function existed that will use a pattern, target
variables, interval & a data source for polling & parsing information
regularly.

For example, this function could be told to poll ACPI power status
every X seconds and put the result into $foo. The same function
could also keep track of unread mail, the temperature of CPU, HDD,
etc and pretty much antything else you can get from a file or
program and put all of those values into variables.

Does any function like this exist?

Richard

Aaron Davies | 7 Aug 08:53

Multi-Minute Startup?

It takes zsh multiple minutes (around 3) to start up on a new server I
just got access to. I have no custom .z* files at this point, so all
that's running should be the /etc files, of which only /etc/zshenv and
/etc/zshrc are actually present. Any ideas what's likely to be slowing
me down so much?
--

-- 
Aaron Davies
aaron.davies <at> gmail.com

Mihai Criveti | 5 Aug 12:44

Yodl has been discontinued for 13 years... zsh still uses it for texi docs?

I've had some issues building ZSH from CVS on AIX. Turns out it doesn't build zsh.texi, which requires yodl to build.

http://www.xs4all.nl/~jantien/yodl/ says it's been discontinued for 13 years now.. (4 years in 1999 when that page was last updated).

I'm also having a hard time finding the thing on any ftp mirror (it's been taked down). Finally managed to track in down in a Debian repo.

Is there a specific reason zsh doesn't move to texinfo or something or is there an updated version of yodl around (I've failed to find one).

Criveti Mihai
http://unixsadm.blogspot.com

Mihai Criveti | 4 Aug 15:32

ZSH 4.3.6 fails to compile (module.c: 1453) on AIX 5300-08-01 (AIX 5.3 TL 8), ZSH 4.2.7 compiles

Hi. I'm trying to build zsh 4.3.6 on AIX 5300-08-01 using gcc 4.2.4
and Autoconf 2.61. Configure works fine, but the build fails after
some time with:

        gcc -c -I.  -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -O2  -o
linklist.o linklist.c
        gcc -c -I.  -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -O2  -o
loop.o loop.c
        gcc -c -I.  -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -O2  -o
math.o math.c
        gcc -c -I.  -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -O2  -o
mem.o mem.c
        gcc -c -I.  -DHAVE_CONFIG_H -Wall -Wmissing-prototypes -O2  -o
module.o module.c
module.c: In function 'load_and_bind':
module.c:1453: warning: assignment from incompatible pointer type
module.c:1454: error: 'struct module' has no member named 'flags'
module.c:1455: error: 'struct module' has no member named 'flags'
make: 1254-004 The error code from the last command is 1.

Stop.
make: 1254-004 The error code from the last command is 2.

Stop.
make: 1254-004 The error code from the last command is 2.

Stop.

That line in module.c looks like:

 if (!(m->flags & MOD_ALIAS) && m->u.handle && !(m->flags &
         MOD_LINKED)) err |= loadbind(0, m->u.handle, ret);

Like I've said, I'm happily running ZSH 4.2.7 so this is probably some
newly introduced issue.

--

-- 
Criveti Mihai
http://unixsadm.blogspot.com

Max Mikhanosha | 4 Aug 07:09

zle widgets coolness: pipe command template

Wrote my first zle widget, thought I'll share:

# define-pipe-widget <widget-name> "template1" "template2" ....
#
# Defines "pipe widget" templates. Its hard to describe the best way
# is through an example:
#
# define-pipe-widget insert_grep  "grep \"@@@\"" "grep -i \"@@@\"" "grep @@@" 
# define-pipe-widget insert_head "head" "head\n"
#
# bindkey "\M-g" insert_grep
# bindkey "\M-h" insert_head
#
# Now pressing Alt-G will insert (| represents cursor position)
#
# On empty command line: grep "|"
#
# On non-empty command line: <old cmdline> | grep "|"
#
# Pressing Alt-G one more time cycles through choices
# ie:
#  ... |  grep "|"
#  ... | grep -i "|"
#  ... | grep
#  
# If template has \n in the end, then it will be auto-accepted:
# 
#      Alt-H does: ... | head <cursor here>
#  2nd Alt-H does  ... | head<Enter>
#
declare -gA pipe_widgets
function define-pipe-widget () {
    local var=$1 
    local templates=_${var}_templates
    declare -ga $templates
    shift
    set -A $templates $@
    zle -N $var insert-pipe-command
}

insert-pipe-command () {
    emulate -L zsh
    local var=$WIDGET
    local templates=_${var}_templates
    local before after auto_accept same patnum

    set nomatch
    # see if command line is same as in our last invocation
    if [[ $CURSOR == ${pipe_widgets[cursor_$var]} 
                && $HISTNO == $pipe_widgets[histno_$var] 
                && $BUFFER == $pipe_widgets[buffer_$var] ]] ; then
        (( patnum = ++pipe_widgets[patnum_$var] ))
        # wrap around
        if [[ $patnum -gt ${#${(P)templates}}  ]] ; then
            (( patnum = pipe_widgets[patnum_$var] = 1 ))
        fi
        BUFFER=$pipe_widgets[buffer_before_$var]
        CURSOR=$pipe_widgets[cursor_before_$var]
    else
       # start from scratch
       (( patnum = pipe_widgets[patnum_$var] = 1 ))
       pipe_widgets[buffer_before_$var]=$BUFFER
       pipe_widgets[cursor_before_$var]=$CURSOR
    fi
    local tmp=${${(P)templates}[$patnum]}
    if [[ $tmp == *\\n ]] ; then
        auto_accept=1
        tmp=$tmp[1,-3]
    fi
    # cursor in the end if not specified
    if [[ $tmp != *@@@* ]] ; then
        tmp="${tmp}@@@"
    fi
    before=${tmp%@@@*}
    after=${tmp#*@@@}
    if [[ -n ${LBUFFER## *} ]] ; then
        RBUFFER+=" | "
    else
        if [[ $after == '' && $before[-1] != " " ]] ; then
            before+=" "
        fi
        auto_accept=
    fi
    RBUFFER+=$before$after
    CURSOR=$(( $#BUFFER - $#after))
    # incase we were in vi mode
    builtin zle vi-insert 
    if [[ $auto_accept == 1 ]] ; then
        builtin zle accept-line
    fi
    pipe_widgets[histno_$var]=$HISTNO
    pipe_widgets[buffer_$var]=$BUFFER
    pipe_widgets[cursor_$var]=$CURSOR
}

Tomasz Pala | 1 Aug 18:29

completion: highlight matching part

Hi,

is it possible for zsh to highlight (bold, change color etc.) of
matching part of available completions? E.g.

$ ls abcd[tab]
abcd123		abcd456		abcd789
abcdefg		abcdhij		abcdklm

and I'd like the 'abcd' to be lightgreen.

Now it's sometimes hard to find out what character to type next, this
solution would make it easier.

--

-- 
Tomasz Pala <gotar <at> pld-linux.org>

Julien Duval | 1 Aug 15:05

Setting the cursor position upon completion

Hi,
I've come to you cause I'm having some trouble setting the cursor position upon completion, and I didn't find a satisfying solution on the web.
My TAB key is bound to the expand-or-complete-prefix widget and I've set the MENU_COMPLETE option in order to cycle through all the matches right from the first TAB hit.
The thing is, when cycling through the matches, the cursor is always moved to the end of each match, which I don't want.


Here is the behaviour I'm looking for:

When hitting TAB for the first time and the first match is inserted,

(1) if there is more than one match and all of them share a common unambiguous prefix, then move the cursor to the position immediately following the prefix (that is the first ambiguous character).

(2) if there is more than one match but they do not ALL share a common prefix, then leave the cursor where it was before hitting TAB. This is actually implied by (1).

(3) if there is only one single match, then move the cursor to the end of the match inserted.


The default behaviour already satisfies (3). But I can't seem to find a solution for the other two.

I've tried the following command to solve (1), but unfortunately it didn't help and I don't understand why.
zstyle ':completion:*' ambiguous true

I've unset the ALWAYS_TO_END option (even though it's already the case by default) but it didn't change anything. Set or unset, the cursor is always moved to the end of the match. Does anyone know the point of this option ?


Hope the description and my English weren't too confusing.
Any help would be greatly appreciated.

Thanks,
Julien

Envoyé avec Yahoo! Mail.
Une boite mail plus intelligente.
Anthony Fletcher | 31 Jul 21:48

recurse up

One can find files that live below the current directory via

	ls **/README

but how can one look for files in the parent, grand-parent, ...
directories?

For example, suppose that the file /a/README exists and the current
directory is /a/b/c/d/e. Then, I'd like

	ls .../README

to glob expand to ../../../README.

Any suggestions?

			Anthony.

Ronald Fischer | 29 Jul 13:24

approximate filename globbing

I have trouble understanding the "Approximate Matching" section
in the zsh manual.

Assume I have in my directory files cn1.pl, cn2.pl, cn3.pl, and
I use the following glob pattern:

  ls (#a2)cnx.pl

I had expected to see all my cn?.pl displayed, but instead I 
get a "zsh: no match" error.

How do I correctly use (#a...) for globbing?

Ronald
--

-- 
Ronald Fischer <ronaldf <at> eml.cc>
+  If a packet hits a pocket on a socket on a port, 
+  and the bus is interrupted and the interrupt's not caught,
+  then the socket packet pocket has an error to report.
+		(cited after Peter van der Linden)

Max Mikhanosha | 29 Jul 04:44

PATCH: option for completion file-sort to follow symlinks

I have all my dotfiles under version control in a separate directory,
and ~/.zshrc ~/.zalias etc are symlinks to the version controlled
directory.

So even when I have: "zstyle ':completion:*:*:*:*' file-sort date"
doing vi ~/.z<Tab> sorts the files based on symlink modtime and not
the file that its pointing to.

The one line patch included into the end of this email adds one
additional option `follow' to the file-sort, which makes it follow
symlinks.

# follow symlinks when sorting
zstyle ':completion:*:*:*:*' file-sort date follow

Regards,
  Max

Index: Completion/Unix/Type/_path_files
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_path_files,v
retrieving revision 1.25
diff -u -r1.25 _path_files
--- Completion/Unix/Type/_path_files	7 Mar 2006 12:52:27 -0000	1.25
+++ Completion/Unix/Type/_path_files	29 Jul 2008 02:43:12 -0000
@@ -113,6 +113,7 @@
   *)                  sort=on;;
   esac
   [[ "$tmp1" = *rev* ]] && sort[1]=O
+  [[ "$tmp1" = *follow* ]] && sort="-$sort"

   if [[ "$sort" = on ]]; then
     sort=


Gmane