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

This commit is contained in:
brad Arant committed 2025-11-07 19:35:07 -08:00
1 parent bdbae9e397
commit 96302e1d27
2 files changed
+23 -5

No files matched your search

+14 -3
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) {