NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Help with BSD make
On Sat, Jul 14, 2012 at 01:51:35PM +0200, tlaronde%polynum.com@localhost wrote:
> On Sat, Jul 14, 2012 at 01:40:17PM +0200, Petar Bogdanovic wrote:
> > On Sat, Jul 14, 2012 at 09:59:11AM +0100, Sad Clouds wrote:
> > > Hello, I'm learning make(1), so a bit of a daft question:
> > >
> > > all: .PHONY
> > > cd /tmp
> > > pwd
> > >
> > > This gives
> > >
> > > cd /tmp
> > > make: exec(cd) failed (No such file or directory)
> > > *** Error code 1
> >[...]
> > -cd /foo \#
> > # cd /foo \#
> > # /bin/sh: line 0: cd: /foo: No such file or directory
> > # *** Error code 1 (ignored)
> >
>
> Since the instruction block has no escaped newlines---i.e. the shell is
> supposed to treat one line after the other--- the cd(1) has no effect
> and can have no effect. It seems that make catches the error. To cd to
> /tmp AND have pwd print /tmp you have to escape or put everything on
> one line:
That's not really the issue here. Besides, nbmake ``executes all
commands for a given target using a single shell invocation'' except
when -B was specified. See make(1), COMPATIBILITY.
In the example above (cd /foo) make fails to execve a program called cd,
and does not execute any shell prior to that. It also fails because of
the same reason when given two args (cd /foo /bar) but passes the lines
correctly to sh if one of the arguments contains a shell metacharacter
(like $ or #).
Petar Bogdanovic
Home |
Main Index |
Thread Index |
Old Index