I want make one-liner that creates zipped file with python code. However when I run it in Makefile, it uses the default shell (dash). Is the
bash$ dash
dash$ zip --exclude '.git/*' --exclude '*.swp' --exclude '*.pyc' --exclude 'tool' --exclude Makefile -r - . | cat <(echo '#!/usr/bin/env python') - > externaltool
dash: 1: Syntax error: "(" unexpected
dash$ exit
But in bash it works perfectly well
bash$ zip --exclude '.git/*' --exclude '*.swp' --exclude '*.pyc' --exclude 'externaltool' --exclude Makefile -r - . | cat <(echo '#!/usr/bin/env python') - > externaltool
adding: common/ (stored 0%)
adding: common/config.py (deflated 19%)
adding: common/cmdwrap.py (deflated 65%)
adding: common/extconfig.py (deflated 71%)
adding: common/commands.py (deflated 19%)
adding: common/__init__.py (stored 0%)
adding: __main__.py (deflated 45%)
Is there any method to express cat <(echo '#!/usr/bin/env python') - in dash ?
I know I can add to Makefile
SHELL := /bin/bash
but it is just workaround rather than pernament solution.
No. dash doesn't support process substitution.
But that's also a rather strange way to do what you want there.
Two simpler (and dash compatible unless I'm sorely mistaken) ways are:
{ echo '#!/usr/bin/env python'; zip --exclude '.git/*' --exclude '*.swp' --exclude '*.pyc' --exclude 'tool' --exclude Makefile -r - .; } > externaltool
and
echo '#!/usr/bin/env python' > externaltool
zip --exclude '.git/*' --exclude '*.swp' --exclude '*.pyc' --exclude 'tool' --exclude Makefile -r - . >> externaltool`