Berkeley CSUA MOTD:Entry 22882
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/25 [General] UID:1000 Activity:popular
5/25    

2001/10/31 [Computer/SW/Languages/C_Cplusplus] UID:22882 Activity:very high
10/31   How can I save the output of a subshell command into a Makefile
        variable? I want something like TIMESTAMP=`date '+%Y-%b-%d-%H:%M'`,
        and then use that in the following rule:
        checkpoint : clean
                tar cf ../$(TIMESTAMP).tar .
        ------------
        But instead of returning the date string, it makes tar files named
        date '+%Y-%b-%d-%H:%M'.tar ... What am I doing wrong?
        \_ 1. Which shell?
           2. Loose the brackets. They have a special meaning in most shells
           3. Post the exact commands/script you're trying to run
        \_ What version of make?  From Solaris 8 make(1S)
        \_ What version of make?  From Solaris 8 make(1S) -jon
  Command Substitutions
     To incorporate the standard output of a shell command  in  a
     macro, use a definition of the form:

        MACRO:sh =command

     The command is executed only once, standard error output  is
     discarded,  and NEWLINE characters are replaced with SPACEs.
     If the command has a non-zero exit status, make  halts  with
     an error.

     To capture the output of a shell command in a  macro  refer-
     ence, use a reference of the form:

        $(MACRO:sh)

     where MACRO is the name of a macro containing a valid Bourne
     shell  command  line.  In this case, the command is executed
     whenever the reference is evaluated.  As with shell  command
     substitutions,  the  reference is replaced with the standard
     output of the command. If the command has  a  non-zero  exit
     status, make halts with an error.
2025/05/25 [General] UID:1000 Activity:popular
5/25    

You may also be interested in these entries...
2008/4/15-23 [Computer/Companies/Google] UID:49755 Activity:high
4/15    Anyone got any random investment tips? I am kinda at a loss of what to do.
        Agriculture and energy are at record highs...
        \_ stockhouse.ca .. NOT - via NOSOF ... assay results coming in soon
        \_ I'm liking HRP, currently paying 12.2% dividend; there's some
           risk, but they shouldn't be as exposed to some of the macro
           issues as a lot of stocks.  Ex-div is coming up next week.
	...