Opened 3 months ago

Last modified 2 months ago

#3996 new enhancement

Allow multiple --exec's

Reported by: jidanni Owned by: grass-dev@…
Priority: trivial Milestone: 7.8.3
Component: Startup Version: git-releasebranch78
Keywords: exec grass.py init Cc:
CPU: Unspecified Platform: Unspecified

Description

Enhancement idea:

Even though one can run whole shell scripts, how about also allowing more than one "grass --exec"?

Perhaps allow multiple --exec's using Unix find(1)'s method:

-exec ... ... \; -exec ... ... \;

In fact it one fails, don't run the rest, just like Unix.

Change History (7)

comment:1 Changed 3 months ago by mankoff

Somewhat related - you can use HEREDOCs:

rm -fR ~/tmp/G
grass -c EPSG:3413 ./tmp/G --exec <<EOF
g.region -p
g.region e=100 n=100 res=10 -p
EOF
Last edited 3 months ago by mankoff (previous) (diff)

comment:2 in reply to:  1 Changed 3 months ago by jidanni

Replying to mankoff:

Somewhat related - you can use HEREDOCs

Great to know, and should be documented.

(Alas I am mainly doing one-liners in Makefiles.)

comment:3 Changed 3 months ago by mankoff

HEREDOCs work in Makefiles.

This seems like a bad idea https://stackoverflow.com/questions/5873025/heredoc-in-a-makefile

comment:4 in reply to:  3 Changed 3 months ago by jidanni

Replying to mankoff:

HEREDOCs work in Makefiles.

This seems like a bad idea...

Yup, and that's why I learned perl while the other kids learned python. At least good old ";"'s still work in Makefiles.

Last edited 3 months ago by jidanni (previous) (diff)

comment:5 Changed 3 months ago by wenzeslaus

Keywords: exec grass.py init added

Replying to jidanni:

Replying to mankoff:

Somewhat related - you can use HEREDOCs

Great to know, and should be documented.

It does not work in a way, at least I think, it should work, so that's partially the reason it is not in documentation. There is actually a ticket for it: #2639, so I suggest have further discussion on this there (if needed).

comment:6 in reply to:  description Changed 3 months ago by wenzeslaus

Back to the --exec ... \; --exec ... \; enhancement:

Before somebody dives into implementing this. Do you want to elaborate on the syntax, use cases, examples, edge cases, and similarities (and differences) to other tools besides find. That would be good to have before committing to support additional syntax when there are other ways to achieve the same (for example, aforementioned here document, an .sh script, or --exec bash -c "... ; ...;".)

comment:7 Changed 2 months ago by neteler

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.