Note that there are some explanatory texts on larger screens.

plurals
  1. POExecute complex shell command from makefile
    primarykey
    data
    text
    <p>I have the following command line that works from the Linux command prompt:</p> <pre><code>vi /tmp/test.txt -s &lt;( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" ) </code></pre> <p>It creates a temporary file (using Process Substitution) that contains the following <code>vim</code> command:</p> <pre><code>:1 s/^\/\/ VERSION: .*$/\/\/ VERSION: $(date)/g </code></pre> <p>It opens file <code>/tmp/test.txt</code> for editing and executes the command from the previously created temporary file. It finds line 1 and replaces the line with a current time stamp. It looks a bit like this:</p> <pre><code>// VERSION: Fri Apr 12 21:20:03 CEST 2013 ... ... </code></pre> <p>Next I can do any required editing and only when I decide to save the file, all changes are commited to disk. It is not an option to first change the file on disk, then start the editor, as the file will have a different timestamp while the contents itself didn't change.</p> <p>So far it works as designed / intended.</p> <p>Now I'm trying to move this vi command line into a make file and that is where I fail. I tried a <code>$(shell .....)</code> construction, but make is throwing errors at me.</p> <pre><code>edit: $(shell vi $(src).cpp -s &lt;( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" ) </code></pre> <p>I'm trying to figure out how the line in the Makefile should read fiddling with extra quotes and parentheses, but I haven't solved it yet.</p> <p>I am running Ubuntu Linux 12.10 and GNU Make 3.81</p> <h3><code>vi project.cpp -s &lt;( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" )</code></h3> <p>Make doesn't seem to like the "Process Substitution" construction <code>&lt;( command )</code>. I do not want to use an extra (real) file.</p> <pre><code>€ make edit vi project.cpp -s &lt;( echo ":1 s/^\/\/ VERSION: .*$/\/\/VERSION: $(date)/g" ) /bin/sh: 1: Syntax error: "(" unexpected make: *** [edit] Error 2 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload