zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: functions/Completion/Linux/_modutils
Date: Tue, 13 May 2008 20:17:14 -0700	[thread overview]
Message-ID: <080513201714.ZM10079@torch.brasslantern.com> (raw)
In-Reply-To: <4829BF7A.20203@sergio.spb.ru>

On May 13,  8:19pm, sergio wrote:
}
} When i'm not root  modprobe is not in my path, so
} in case "all_modules)" "modules" will be empty:

When completing for what?  An example command line would be helpful.

}   all_modules)
}     modules=( ${${${${(f)"$(_call_program modules
} ${(M)words[1]##*/}modprobe -l 2>/dev/null)"}:#}##*/}%%.*} )
} 
} words --- what this?

It's the command line broken out into an array of the $IFS-separated
substrings.  Each such substring is called a "word" in the semi-formal
shell grammar described in the manual page.

So ${(M)words[1]##*/} should be the path prefix of the command name.
For example, if you are completing after /sbin/lsmod, then that
expansion is /sbin/ which is then prefixed to modprobe.  The idea is
that if modprobe isn't in your path, the best place to look for it
is in the same place as whatever other command (assumed also not to
be in your path and therefore a full path name) you are completing.

} with
} modules=( ${${${${(f)"$(_call_program modules
} ${(M)words[1]##*/}/sbin/modprobe -l 2>/dev/null)"}:#}##*/}%%.*} )
} all works fine

Except if you complete after /sbin/rmmod, the completion will try to
run /sbin//sbin/modprobe and break.


  reply	other threads:[~2008-05-14  3:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-13 16:19 functions/Completion/Linux/_modutils sergio
2008-05-14  3:17 ` Bart Schaefer [this message]
2008-05-14 14:16   ` functions/Completion/Linux/_modutils sergio
2008-05-14 15:18     ` functions/Completion/Linux/_modutils Peter Stephenson
2008-05-14 15:56       ` functions/Completion/Linux/_modutils sergio
2008-05-14 15:55     ` functions/Completion/Linux/_modutils Bart Schaefer
2008-05-14 16:19       ` functions/Completion/Linux/_modutils sergio
2008-05-14 16:40         ` functions/Completion/Linux/_modutils Bart Schaefer
2008-05-15 12:16           ` functions/Completion/Linux/_modutils Clint Adams
2008-05-15 16:58             ` functions/Completion/Linux/_modutils Bart Schaefer
2008-05-15 17:00               ` functions/Completion/Linux/_modutils Peter Stephenson
2008-05-16  9:26                 ` functions/Completion/Linux/_modutils Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=080513201714.ZM10079@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).