Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: functions/Completion/Linux/_modutils



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.



Messages sorted by: Reverse Date, Date, Thread, Author