GOLF(2gg)
๐ GOLF(2gg) โ the exec-program glow-up
okay bestie, welcome to the GOLF(2gg) page from the Development section, and no cap this one is a banger ๐
โจ NAME โจ
exec-program โ (program-execution) ๐ซถ
๐ฏ PURPOSE ๐ฏ
Run a program. That's it, that's the whole vibe. execute it. ๐
๐ SYNTAX ๐
exec-program <program path> \
[ args <program arg> [ , ... ] ] \
[ status <exit status> ] \
[ ( input <input string> [ input-length <string length> ] ) \
| ( input-file <input file> ) ] \
[ ( output <output string> ) \
| ( output-file <output file> ) ] \
[ ( error <error string> ) | ( error-file <error file> ) ]
๐ DESCRIPTION ๐
exec-program runs whatever program you point it at with <program path>, and bestie, that path can be three whole things:
- a program name with no path, as long as it lives somewhere in the path given by the
PATHenvironment variable ๐ - an absolute path ๐ซ
- a path relative to the application home directory (peep
directoriesfor that, iykyk)
A program can take input arguments โ you hand those over as strings in the args clause. Got more than one? Separate them with a comma, periodt. There's no limit on how many input arguments you can pass, other than whatever the underlying Operating System says, and the OS is the one setting the rules there ๐ญ
You can also name a status variable, <exit status>, and it'll hold the program's exit status. Quick heads up though: if the program got terminated by a signal, <exit status> is 128+signal_number. So say the program got killed with signal 9 (the KILL signal, iconic but rude ๐), then <exit status> is 137 (that's 128+9). And any other kind of abnormal program termination โ like, where the program just did not set the exit code โ returns 126 as <exit code>. Noted, bestie ๐
Specifying program input and output is optional, it's giving very chill. But if the program has output and you're not capturing it in any way at all, that output gets redirected to a temporary file, and that file gets deleted once exec-program is done. Cute, clean, no leftovers ๐
You can pass an <input string> straight to the program's standard input (stdin) using the input clause. If you don't use input-length, the length of that input is just the string length of <input string> โ otherwise, <string length> bytes get passed to the program. Or, if you'd rather, you can name a file <input file> with the input-file clause, and it gets opened and directed into the program's standard input (stdin) ๐ธ
Want the program's output (that's "stdout") in a file? <output file> via the output-file clause, slay. Or you can capture the program's output in <output string> via the output clause instead ๐
For the program's error output (that's "stderr"), use the error-file clause to get it into <error file>. Or capture the program's error output in <error string> via the error clause. Pick your fighter โจ
Now the important part, listen up:
If<input file>can't be opened,GG_ERR_READis reported in<exit status>. And if either<output file>or<error file>can't be opened, the status isGG_ERR_WRITE. ๐ค
Also, in general, a program counts as successfully executed if it returns GG_OKAY (that's zero, the zero of dreams). Most programs returning a non-zero value mean failure, and we respect that ๐ซก
๐ EXAMPLES ๐
just run it, no extras
To simply execute a program that's in the path, with no arguments, no input, no output:
exec-program "myprogram"
grep era ๐
Run the grep program using a string as its standard input, to remove a line that contains "bad line" in it, and output the result into the ovar variable:
exec-program "grep" args "-v", "bad line" "config" input "line 1\nline 2\nbad line\nline 3" output ovar
print-out ovar
list the files, get the list ๐
Get the list of files in the application home directory into buffer ovar and then display it:
exec-program "ls" output ovar
ls but extra โจ
Similar to the example above of listing files, but output results to a file (which is then read and the result displayed), and provide options "-a -l -s" to the ls program:
exec-program "ls" args "-a", "-l", "-s" output-file "lsout"
read-file "lsout" to final_res
print-out final_res
wc said count them lines ๐งฎ
Count the lines of file config (which is redirected to the standard output of the wc program) and store the result in the variable ovar (by redirecting the output of the wc program into it), and then display:
exec-program "wc" args "-l" input-file "config" output ovar
print-out ovar
๐ SEE ALSO ๐
- Program execution
exec-program exit-status- See all documentation
and that's the whole page, bestie!! you ate that ๐โจ this lil masterpiece is rockin' version $VERSION and it's dated $DATE, brought to you by the GOLF(2gg) girlies ๐ bye diva, go execute something iconic ๐ฆ
๐ฆ where this page comes from
- ubuntu questing: golf 601.4.41-1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms