rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Robert Earl <chupchup@piggy.ucsb.edu>
To: rc@archone.tamu.edu
Subject: exec'ing with relative pathname
Date: Fri, 27 Sep 1991 21:12:07 -0500	[thread overview]
Message-ID: <9109280312.AA09895@piggy.ucsb.edu> (raw)

I reported this problem to Byron earlier, and since then I've realized
why he got different results than I did...

The rc manpage says this:

                                       The first word of  a  com-
     mand  is  the name of that command.  If the name begins with
     /, ./, or ../, then the name is used  as  an  absolute  path
     name  referring  to an executable file.  Otherwise, the name
     of the command is looked up in a table of  shell  functions,
     builtin  commands,  or as a file in the directories named by
     $path.

Now, say I have a binary in a temporary directory under the current
one, and I want to run it, I type in a command like

; tmp/foo

rc reports "tmp/foo not found" (for me)

According to the manpage, this isn't an absolute pathname and the
search in functions, builtins, and $path is done.  All other shells
seem to treat this just like

$ ./tmp/foo

which seems correct to me, mostly because the UNIX (and others :)
idiom `open("tmp/foo", ..)' wants to open a file relative to the
current directory.

Byron tested this out and told me it worked "right" for him (it found
./tmp/foo); but it occurred to me that maybe "." was in his path (it's
not in mine), which means yes, eventually the $path search matched
"./tmp/foo" and it found the command.  For me, it never even tried
"./tmp/foo"; it did try $home/bin/sun4/tmp/foo, $home/bin/tmp/foo,
/usr/local/bin/tmp/foo, ad nauseum.

sh's rule is worlds simpler than rc's, and I don't see any reason not
to make rc do the same:

                                   If the command name contains a
     / the search path is not used.  Otherwise, each directory in
     the  path  is  searched for an executable file.

What does everyone else think?



robert earl		rearl@piggy.ucsb.edu
ella megalast burls forever


             reply	other threads:[~1991-09-28  3:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-09-28  2:12 Robert Earl [this message]
1991-09-28  3:27 ` Chris Siebenmann
1991-09-30 15:54 Donn Cave

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=9109280312.AA09895@piggy.ucsb.edu \
    --to=chupchup@piggy.ucsb.edu \
    --cc=rc@archone.tamu.edu \
    /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.
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).