From 3b467e2c0aecf36c0f13310f95bcf801a419ad21 Mon Sep 17 00:00:00 2001 From: Master Date: Wed, 1 Jul 2020 22:57:32 -0400 Subject: [PATCH] added shell attribute to unit object definition to allow more flexibility; defaults to sh --- src/Sproc/Sproc.cpp | 13 ++++--------- test/components/independent_test_1.bash | 7 ++----- test/examplar.variables | 6 +++++- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Sproc/Sproc.cpp b/src/Sproc/Sproc.cpp index e78d172..ece0aba 100644 --- a/src/Sproc/Sproc.cpp +++ b/src/Sproc/Sproc.cpp @@ -95,15 +95,10 @@ int Sproc::execute( std::string shell, std::string environment_file, std::string return -401; } - std::string sourcer_string = shell + " -c '. " + environment_file + "'"; - slog.log( E_DEBUG, "Shell call for loading: ``" + sourcer_string + "``." ); - int sourcer = system( sourcer_string.c_str() ); - if ( sourcer != 0) - { - slog.log(E_FATAL, "Failed to source environment file."); - return -127; - } - exit_code_raw = system( command.c_str() ); + std::string sourcer = shell + " -c \". " + environment_file + " && " + command + "\""; + slog.log( E_DEBUG, "Shell call for loading: ``" + sourcer + "``." ); + std::cerr << sourcer.c_str() << std::endl; + exit_code_raw = system( sourcer.c_str() ); exit( WEXITSTATUS( exit_code_raw ) ); } else if ( pid > 0 ) { diff --git a/test/components/independent_test_1.bash b/test/components/independent_test_1.bash index 95c660b..03c99ff 100755 --- a/test/components/independent_test_1.bash +++ b/test/components/independent_test_1.bash @@ -1,9 +1,6 @@ -whoami -id +#!/bin/bash -touch /home/bagira/testfile - -stat /home/bagira/testfile +echo "Test var is: $TEST_VAR" #dialog --stdout --title "Interact with me!" \ # --backtitle "This is user interaction." \ diff --git a/test/examplar.variables b/test/examplar.variables index d10a126..2b9747e 100644 --- a/test/examplar.variables +++ b/test/examplar.variables @@ -1 +1,5 @@ -echo "This is output from loading the variables file." \ No newline at end of file +set -a + +echo "This is output from loading the variables file." +TEST_VAR="999" +