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: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:

        -cd /foo\
  pwd

  or

  -cd /foo; pwd

The last example (SHELL error) is probably because make errors if only
blanks till the end of the unescaped new line (with only cd, that is at
best a no-op).

-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                      http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index