Added ability for call tag to use container as input stream.

This commit is contained in:
brad Arant 2025-11-07 19:35:07 -08:00
parent bdbae9e397
commit 96302e1d27
2 changed files with 23 additions and 5 deletions

View File

@ -1,3 +1,4 @@
#include "__call.h"
#include "Exception.h"
#include "MString.h"
@ -11,8 +12,8 @@
namespace jet {
__call::__call(coreutils::ZString &in, coreutils::MString &parentOut, Global &global, Tag *parent, Tag *local) : Tag(in, parentOut, global, parent, local) {
if(hasContainer)
throw coreutils::Exception("call tag cannot have a container.");
if(hasContainer && keywordDefined("input"))
throw coreutils::Exception("call tag cannot have both input keyword and have a container.");
if(!keywordDefined("pgm"))
throw coreutils::Exception("pgm keyword must be specified.");
for(ix = 0; ix <= 50; ++ix)
@ -31,7 +32,17 @@ namespace jet {
if(pid == 0) {
close(fdo[0]);
dup2(fdo[1], 1);
if(keywordDefined("input")) {
if(hasContainer) {
pipe(fdi);
if(fork() == 0) {
close(fdi[0]);
write(fdi[1], container.getData(), container.getLength());
close(fdi[1]);
exit(0);
}
close(fdi[1]);
dup2(fdi[0], 0);
} else if(keywordDefined("input")) {
coreutils::MString input(resolveKeyword("input"));
pipe(fdi);
if(fork() == 0) {

View File

@ -1,11 +1,18 @@
#!../jet-2.0
<jet name1="localname" filterblanklines="true" trimlines="true">
<jet name1="localname" filterblanklines="false" trimlines="true">
<set name="abc" value="abcdefg" />
<call pgm="cat" error="error" input="$[abc]xyz" name="test1" />
test1=$[test1]
name1=$[%name1]
error=$[error]
<call error="rc" pgm="/usr/bin/ls" arg1="-al" />
<call error="rc" pgm="ls" arg1="-al" />
$[rc]
<call pgm="cat" filterblanklines="false">
From: barant@barant.com
To: brad.arant@gmail.com
Subject: This is a test email.
This is a test email being sent from a jet script with a single
call command.
</call>
</jet>