Path/executable() Bug

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Path/executable() Bug

Paul-425
The executable() function cannot find files that are in the $PATH, where the file's path element contains a tilde.

For example, I have a /home/paul/bin/xsel executable. With my $PATH set to ~/bin:...etc, the code below prints the error message,

xsel not found in ~/bin:/home/paul/.vim/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/kde4/libexec:/usr/lib/qt/bin:/opt/kde3/lib/qt3/bin:/opt/kde3/bin:/usr/share/texmf/bin:.

With my path set to /home/paul/bin:...etc, the code prints

xsel found in /home/paul/bin:/home/paul/.vim/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/kde4/libexec:/usr/lib/qt/bin:/opt/kde3/lib/qt3/bin:/opt/kde3/bin:/usr/share/texmf/bin:.

if executable('xsel')
     echon "xsel found"
else
     echon "xsel not found"
endif
echon " in " . $PATH

When my $PATH is either of the two, I can run xsel just fine from anywhere, from the bash command line.

VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 11 2010 16:09:27)
Included patches: 1-394
Compiled by <[hidden email]>
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte
+multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra +perl +postscript
+printer +profile +python +quickfix +reltime +rightleft -ruby +scrollbind
+signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
    system vimrc file: "$VIM/vimrc"
      user vimrc file: "$HOME/.vimrc"
       user exrc file: "$HOME/.exrc"
   fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -D_FORTIFY_SOURCE=1    -D_REENTRANT -D_GNU_SOURCE  -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64  -I/usr/lib/perl5/5.10.1/i486-linux-thread-multi/CORE  -I/usr/include/python2.6 -pthread
Linking: gcc   -Wl,-E   -L/usr/local/lib -o vim       -lncurses -lacl -lgpm   -Wl,-E  -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/5.10.1/i486-linux-thread-multi/CORE -lperl -lcrypt -lutil -lc -L/usr/lib/python2.6/config -lpython2.6 -lpthread -lutil -lm -Xlinker -export-dynamic

--

.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Path/executable() Bug

iler.ml
On Mar 29, 1:06 am, Paul <[hidden email]> wrote:
> The executable() function cannot find files that are in the $PATH, where the file's path element contains a tilde.

The PATH is wrong. Tilde should not appear literally in $PATH, nor
literal '$HOME'.
Make sure PATH does not contain a literal tilde, but rather,
is expansion, the value of $HOME.
Shell won't find executable in such PATH, too.
Try using $HOME when seting PATH, and make sure it is expanded.

Try this in bash:
    bash
    export PATH=$PATH:~/bin
    echo $PATH
Notice tilde is automatically substituted.

It tilde appears in PATH, your PATH is wrong.

Yakov

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Path/executable() Bug

Paul-425
On Mon, Mar 29, 2010 at 02:19:19AM -0700, Yakov wrote:
>Make sure PATH does not contain a literal tilde, but rather,
>is expansion, the value of $HOME.

Yeah, looks like I'll have to do that, but...

>Shell won't find executable in such PATH, too.

...when my $PATH is either of the two, I can run xsel just fine from anywhere, from the bash command line, despite...

>It tilde appears in PATH, your PATH is wrong.

...the tilde being in the path.

--

.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
Reply | Threaded
Open this post in threaded view
|

Re: Path/executable() Bug

iler.ml
On Mar 29, 11:42 am, Paul <[hidden email]> wrote:

> On Mon, Mar 29, 2010 at 02:19:19AM -0700, Yakov wrote:
> >Make sure PATH does not contain a literal tilde, but rather,
> >is expansion, the value of $HOME.
>
> Yeah, looks like I'll have to do that, but...
>
> >Shell won't find executable in such PATH, too.
>
> ...when my $PATH is either of the two, I can run xsel just fine from anywhere, from the bash command line, despite...
>
> >It tilde appears in PATH, your PATH is wrong.

Ok I didn't know some shells do it (interpret literal ~ in PATH), but
other shells don't.
This turns out to be shell-dependent thing:

Shell       Interprets literal~ in PATH ?
-------       -----------------
bash          yes
tcsh           no
csh            no
ksh            no
zsh            no
dash          no      (posix-compatible shell)
ash            no     (another posix-compatibl shell)
-------       -----------------

If you insist on having literal ~ in your $PATH,
then adding this line to ~/.vimrc
will fix results of executable():

let $PATH=substitute($PATH,'\~',$HOME,'g')

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.