Re: surprising behavior: `wildcard' expands tilde, but `shell' doesn't

2000-07-25 Thread Paul D. Smith

%% Eric Hanchrow <[EMAIL PROTECTED]> writes:

  eh> all:
  eh>   @echo wildcard: $(wildcard ~)
  eh>   @echo shell   : $(shell echo ~)

  eh> # GNU Make version 3.78.1 (as shipped with RedHat 6.2)
  eh> # GNU bash, version 1.14.7(1) (as shipped with RedHat 6.2)

  eh> # Here's the output I get:

  eh> # 09:00:28 [erich@emerald erich]$ make -f weird 
  eh> # wildcard: /home/erich
  eh> # shell : ~

  eh> # I would have expected *both* commands to have expanded the tilde,
  eh> # not just the command that calls `wildcard'.

The $(shell ...) function invokes /bin/sh and sends it whatever command
you gave.

Most traditional Bourne shells don't provide the ~ feature; that came
from csh and was adopted by newer Bourne shells like bash and ksh, but
often /bin/sh on a system is a very basic Bourne shell with no fancy
features.  On Linux, /bin/sh is often bash but it starts in a "simple"
mode that doesn't allow more advanced features.

The $(wildcard ...) command uses a builtin globbing library, which is
basically the globbing code from GNU GLIBC (or, if your system is a
Linux box, then it uses the system globbing library since the system
globbing library _is_ GLIBC), rather than the shell.  That globbing
library does understand ~.

HTH.

-- 
---
 Paul D. Smith <[EMAIL PROTECTED]>  Find some GNU make tips at:
 http://www.gnu.org  http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




surprising behavior: `wildcard' expands tilde, but `shell' doesn't

2000-07-25 Thread Eric Hanchrow

all:
@echo wildcard: $(wildcard ~)
@echo shell   : $(shell echo ~)

# GNU Make version 3.78.1 (as shipped with RedHat 6.2)
# GNU bash, version 1.14.7(1) (as shipped with RedHat 6.2)

# Here's the output I get:

# 09:00:28 [erich@emerald erich]$ make -f weird 
# wildcard: /home/erich
# shell : ~

# I would have expected *both* commands to have expanded the tilde,
# not just the command that calls `wildcard'.