Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions stable-patches/MANIFEST.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@ diff --git a/MANIFEST b/MANIFEST
index 985d179..2a1cd25 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1455,6 +1455,8 @@ tests/quotearray2.sub f
@@ -1455,6 +1455,10 @@ tests/quotearray2.sub f
tests/quotearray3.sub f
tests/quotearray4.sub f
tests/quotearray5.sub f
+tests/encodefilevars.tests f
+tests/encodefilevars.right f
+tests/rbash.tests f
+tests/rbash.right f
tests/read.tests f
tests/read.right f
tests/read1.sub f
@@ -1565,6 +1567,7 @@ tests/run-printf f
@@ -1565,6 +1569,8 @@ tests/run-printf f
tests/run-procsub f
tests/run-quote f
tests/run-quotearray f
+tests/run-encodefilevars f
+tests/run-rbash f
tests/run-read f
tests/run-redir f
Expand Down
48 changes: 48 additions & 0 deletions stable-patches/tests/encodefilevars.right.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
diff --git a/tests/encodefilevars.right b/tests/encodefilevars.right
new file mode 100644
index 0000000..0c442f0
--- /dev/null
+++ b/tests/encodefilevars.right
@@ -0,0 +1,42 @@
+Testing _ENCODE_FILE_NEW and _ENCODE_FILE_EXISTING variable handling
+Test 1: Setting _ENCODE_FILE_NEW to UTF-8
+_ENCODE_FILE_NEW=UTF-8
+UTF-8
+Test 2: Setting _ENCODE_FILE_EXISTING to ISO8859-1
+_ENCODE_FILE_EXISTING=ISO8859-1
+ISO8859-1
+Test 3: Changing _ENCODE_FILE_NEW to IBM-1047
+_ENCODE_FILE_NEW=IBM-1047
+IBM-1047
+Test 4: Changing _ENCODE_FILE_EXISTING to UTF-8
+_ENCODE_FILE_EXISTING=UTF-8
+UTF-8
+Test 5: Unsetting _ENCODE_FILE_NEW
+_ENCODE_FILE_NEW=
+_ENCODE_FILE_NEW is not set in environment
+Test 6: Unsetting _ENCODE_FILE_EXISTING
+_ENCODE_FILE_EXISTING=
+_ENCODE_FILE_EXISTING is not set in environment
+Test 7: Setting both variables together
+_ENCODE_FILE_NEW=UTF-8
+_ENCODE_FILE_EXISTING=ISO8859-1
+UTF-8
+ISO8859-1
+Test 8: Verify variables are exported to subshell
+Subshell _ENCODE_FILE_NEW=UTF-8
+Subshell _ENCODE_FILE_EXISTING=IBM-1047
+Test 9: Setting empty value for _ENCODE_FILE_NEW
+_ENCODE_FILE_NEW=
+_ENCODE_FILE_NEW is not set in environment
+Test 10: Setting empty value for _ENCODE_FILE_EXISTING
+_ENCODE_FILE_EXISTING=
+_ENCODE_FILE_EXISTING is not set in environment
+Test 11: Multiple set/unset cycles
+Set 1: _ENCODE_FILE_NEW=UTF-8
+Unset 1: _ENCODE_FILE_NEW=
+Set 2: _ENCODE_FILE_NEW=ISO8859-1
+Unset 2: _ENCODE_FILE_NEW=
+Test 12: Verify variable attributes
+declare -x _ENCODE_FILE_NEW="UTF-8"
+declare -x _ENCODE_FILE_EXISTING="IBM-1047"
+Tests completed
95 changes: 95 additions & 0 deletions stable-patches/tests/encodefilevars.tests.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
diff --git a/tests/encodefilevars.tests b/tests/encodefilevars.tests
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/tests/encodefilevars.tests
@@ -0,0 +1,89 @@
+# Test _ENCODE_FILE_NEW and _ENCODE_FILE_EXISTING environment variable handling
+# These tests verify that bash properly manages z/OS file encoding variables
+
+echo "Testing _ENCODE_FILE_NEW and _ENCODE_FILE_EXISTING variable handling"
+
+# Test 1: Setting _ENCODE_FILE_NEW
+echo "Test 1: Setting _ENCODE_FILE_NEW to UTF-8"
+export _ENCODE_FILE_NEW=UTF-8
+echo "_ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+printenv _ENCODE_FILE_NEW
+
+# Test 2: Setting _ENCODE_FILE_EXISTING
+echo "Test 2: Setting _ENCODE_FILE_EXISTING to ISO8859-1"
+export _ENCODE_FILE_EXISTING=ISO8859-1
+echo "_ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"
+printenv _ENCODE_FILE_EXISTING
+
+# Test 3: Changing _ENCODE_FILE_NEW value
+echo "Test 3: Changing _ENCODE_FILE_NEW to IBM-1047"
+export _ENCODE_FILE_NEW=IBM-1047
+echo "_ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+printenv _ENCODE_FILE_NEW
+
+# Test 4: Changing _ENCODE_FILE_EXISTING value
+echo "Test 4: Changing _ENCODE_FILE_EXISTING to UTF-8"
+export _ENCODE_FILE_EXISTING=UTF-8
+echo "_ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"
+printenv _ENCODE_FILE_EXISTING
+
+# Test 5: Unsetting _ENCODE_FILE_NEW
+echo "Test 5: Unsetting _ENCODE_FILE_NEW"
+unset _ENCODE_FILE_NEW
+echo "_ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+printenv _ENCODE_FILE_NEW || echo "_ENCODE_FILE_NEW is not set in environment"
+
+# Test 6: Unsetting _ENCODE_FILE_EXISTING
+echo "Test 6: Unsetting _ENCODE_FILE_EXISTING"
+unset _ENCODE_FILE_EXISTING
+echo "_ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"
+printenv _ENCODE_FILE_EXISTING || echo "_ENCODE_FILE_EXISTING is not set in environment"
+
+# Test 7: Setting both variables together
+echo "Test 7: Setting both variables together"
+export _ENCODE_FILE_NEW=UTF-8 _ENCODE_FILE_EXISTING=ISO8859-1
+echo "_ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+echo "_ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"
+printenv _ENCODE_FILE_NEW
+printenv _ENCODE_FILE_EXISTING
+
+# Test 8: Verify variables are exported to subshell
+echo "Test 8: Verify variables are exported to subshell"
+export _ENCODE_FILE_NEW=UTF-8
+export _ENCODE_FILE_EXISTING=IBM-1047
+${THIS_SH} -c 'echo "Subshell _ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"; echo "Subshell _ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"'
+
+# Test 9: Setting empty value
+echo "Test 9: Setting empty value for _ENCODE_FILE_NEW"
+export _ENCODE_FILE_NEW=
+echo "_ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+printenv _ENCODE_FILE_NEW || echo "_ENCODE_FILE_NEW is not set in environment"
+
+# Test 10: Setting empty value for _ENCODE_FILE_EXISTING
+echo "Test 10: Setting empty value for _ENCODE_FILE_EXISTING"
+export _ENCODE_FILE_EXISTING=
+echo "_ENCODE_FILE_EXISTING=${_ENCODE_FILE_EXISTING}"
+printenv _ENCODE_FILE_EXISTING || echo "_ENCODE_FILE_EXISTING is not set in environment"
+
+# Test 11: Multiple set/unset cycles
+echo "Test 11: Multiple set/unset cycles"
+export _ENCODE_FILE_NEW=UTF-8
+echo "Set 1: _ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+unset _ENCODE_FILE_NEW
+echo "Unset 1: _ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+export _ENCODE_FILE_NEW=ISO8859-1
+echo "Set 2: _ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+unset _ENCODE_FILE_NEW
+echo "Unset 2: _ENCODE_FILE_NEW=${_ENCODE_FILE_NEW}"
+
+# Test 12: Verify variable attributes
+echo "Test 12: Verify variable attributes"
+export _ENCODE_FILE_NEW=UTF-8
+export _ENCODE_FILE_EXISTING=IBM-1047
+declare -p _ENCODE_FILE_NEW 2>/dev/null || echo "_ENCODE_FILE_NEW variable info not available"
+declare -p _ENCODE_FILE_EXISTING 2>/dev/null || echo "_ENCODE_FILE_EXISTING variable info not available"
+
+# Cleanup
+unset _ENCODE_FILE_NEW
+unset _ENCODE_FILE_EXISTING
+echo "Tests completed"
8 changes: 8 additions & 0 deletions stable-patches/tests/run-encodefilevars.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
diff --git a/tests/run-encodefilevars b/tests/run-encodefilevars
new file mode 100644
index 0000000..0000000
--- /dev/null
+++ b/tests/run-encodefilevars
@@ -0,0 +1,2 @@
+${THIS_SH} ./encodefilevars.tests > ${BASH_TSTOUT} 2>&1
+diff ${BASH_TSTOUT} encodefilevars.right | tee encodefilevars.output && rm -f ${BASH_TSTOUT}
70 changes: 59 additions & 11 deletions stable-patches/variable.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git i/variables.c w/variables.c
index 4e6f93b..a37e258 100644
--- i/variables.c
+++ w/variables.c
diff --git a/variables.c b/variables.c
index 4e6f93b..5bf5db5 100644
--- a/variables.c
+++ b/variables.c
@@ -36,6 +36,10 @@
# include <unistd.h>
#endif
Expand All @@ -13,17 +13,19 @@ index 4e6f93b..a37e258 100644
#include <stdio.h>
#include "chartypes.h"
#if defined (HAVE_PWD_H)
@@ -5757,6 +5761,9 @@ struct name_and_function {
@@ -5757,6 +5761,11 @@ struct name_and_function {
};

static struct name_and_function special_vars[] = {
+#if defined (__MVS__)
+ { "_BPXK_AUTOCVT", sv_bpxk_autocvt },
+ { "_ENCODE_FILE_NEW", sv_encode_file_new },
+ { "_ENCODE_FILE_EXISTING", sv_encode_file_existing },
+#endif
{ "BASH_COMPAT", sv_shcompat },
{ "BASH_XTRACEFD", sv_xtracefd },

@@ -5978,6 +5985,32 @@ sv_globsort (const char *name)
@@ -5978,6 +5987,76 @@ sv_globsort (const char *name)
setup_globsort (name);
}

Expand Down Expand Up @@ -51,21 +53,67 @@ index 4e6f93b..a37e258 100644
+ else if (strcmp(value, "OFF") == 0)
+ __ae_autoconvert_state(_CVTSTATE_OFF);
+}
+
+/* What to do when _ENCODE_FILE_NEW changes. */
+void
+sv_encode_file_new (const char *name)
+{
+ SHELL_VAR *v;
+ char *value;
+
+ v = find_variable (name);
+ if (v == 0 || value_cell (v) == 0)
+ {
+ /* Unbind the variable using Bash's internal function */
+ unbind_variable("_ENCODE_FILE_NEW");
+ return;
+ }
+
+ value = value_cell (v);
+ /* Use Bash's bind_variable with export flag */
+ v = bind_variable("_ENCODE_FILE_NEW", value, 0);
+ if (v)
+ VSETATTR(v, att_exported);
+}
+
+/* What to do when _ENCODE_FILE_EXISTING changes. */
+void
+sv_encode_file_existing (const char *name)
+{
+ SHELL_VAR *v;
+ char *value;
+
+ v = find_variable (name);
+ if (v == 0 || value_cell (v) == 0)
+ {
+ /* Unbind the variable using Bash's internal function */
+ unbind_variable("_ENCODE_FILE_EXISTING");
+ return;
+ }
+
+ value = value_cell (v);
+ /* Use Bash's bind_variable with export flag */
+ v = bind_variable("_ENCODE_FILE_EXISTING", value, 0);
+ if (v)
+ VSETATTR(v, att_exported);
+}
+#endif
+
#if defined (READLINE)
void
sv_comp_wordbreaks (const char *name)
diff --git i/variables.h w/variables.h
index e939e59..719d5ac 100644
--- i/variables.h
+++ w/variables.h
@@ -454,6 +454,10 @@ extern void sv_xtracefd (const char *);
diff --git a/variables.h b/variables.h
index e939e59..304ed3f 100644
--- a/variables.h
+++ b/variables.h
@@ -454,6 +454,12 @@ extern void sv_xtracefd (const char *);
extern void sv_shcompat (const char *);
extern void sv_globsort (const char *);

+#if defined (__MVS__)
+extern void sv_bpxk_autocvt (const char *);
+extern void sv_encode_file_new (const char *);
+extern void sv_encode_file_existing (const char *);
+#endif
+
#if defined (READLINE)
Expand Down
Loading