From 45f9e0ced8fd073961df2b07ce15c2d0adc98409 Mon Sep 17 00:00:00 2001 From: yurc Date: Sat, 3 Oct 2026 20:40:26 +0300 Subject: [PATCH 1/2] linuxcnc_check_ini: make -e/--error work The option loop tested "-h" with a plain "if" after the "-e" branch, so "-e" fell through to the "else" and the script exited with "Unhandled option: '-e'" (exit code 2). Use "elif". Reproduce: linuxcnc_check_ini -e any.ini before: Unhandled option: '-e' after: the INI file is checked and warnings are treated as errors. --- src/emc/ini/linuxcnc_check_ini.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/emc/ini/linuxcnc_check_ini.py b/src/emc/ini/linuxcnc_check_ini.py index 79acb0b8733..83e8997604e 100755 --- a/src/emc/ini/linuxcnc_check_ini.py +++ b/src/emc/ini/linuxcnc_check_ini.py @@ -422,7 +422,7 @@ def main(): if o in ("-e", "--error"): global error_on_warning error_on_warning = True - if o in ("-h", "--help"): + elif o in ("-h", "--help"): usage() # no return from here else: print("Unhandled option: '{}'".format(o), file=sys.stderr); From 9edd1187b667a80357ab5d5b4c08ffd9be903c69 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 19:36:20 +0000 Subject: [PATCH 2/2] tests: add linuxcnc_check_ini -e/--error test The INI file only produces a warning. Without -e the exit value must be 0; with -e or --error warnings are errors and the exit value must be 1. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RZ9Cy18se5jq3dpFgTetJs --- tests/linuxcnc_check_ini/README | 5 +++++ tests/linuxcnc_check_ini/expected | 8 ++++++++ tests/linuxcnc_check_ini/test.sh | 15 +++++++++++++++ tests/linuxcnc_check_ini/warn.ini | 13 +++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/linuxcnc_check_ini/README create mode 100644 tests/linuxcnc_check_ini/expected create mode 100755 tests/linuxcnc_check_ini/test.sh create mode 100644 tests/linuxcnc_check_ini/warn.ini diff --git a/tests/linuxcnc_check_ini/README b/tests/linuxcnc_check_ini/README new file mode 100644 index 00000000000..baf410ed924 --- /dev/null +++ b/tests/linuxcnc_check_ini/README @@ -0,0 +1,5 @@ +Test the exit value of linuxcnc_check_ini with the -e/--error option. + +warn.ini contains only a warning (duplicate entry). Without -e the exit +value must be 0, with -e or --error warnings are treated as errors and the +exit value must be 1. diff --git a/tests/linuxcnc_check_ini/expected b/tests/linuxcnc_check_ini/expected new file mode 100644 index 00000000000..443f5214a62 --- /dev/null +++ b/tests/linuxcnc_check_ini/expected @@ -0,0 +1,8 @@ +warn.ini -> 0 +1 +-e warn.ini -> 1 +1 +--error warn.ini -> 1 +1 +-h -> 2 +0 diff --git a/tests/linuxcnc_check_ini/test.sh b/tests/linuxcnc_check_ini/test.sh new file mode 100755 index 00000000000..d8b26676377 --- /dev/null +++ b/tests/linuxcnc_check_ini/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# Check the exit value of linuxcnc_check_ini with and without -e/--error on +# an INI file that only produces warnings. + +run() { + msgs=$(linuxcnc_check_ini "$@" 2>&1 > /dev/null) + echo "$* -> $?" + echo "$msgs" | grep -c ": warning: " +} + +run warn.ini +run -e warn.ini +run --error warn.ini +run -h +exit 0 diff --git a/tests/linuxcnc_check_ini/warn.ini b/tests/linuxcnc_check_ini/warn.ini new file mode 100644 index 00000000000..38e13a096bd --- /dev/null +++ b/tests/linuxcnc_check_ini/warn.ini @@ -0,0 +1,13 @@ +# Valid configuration except for one duplicated joint entry, which makes +# linuxcnc_check_ini emit a warning (but no error). +[KINS] +KINEMATICS = genhexkins +JOINTS = 1 + +[TRAJ] +LINEAR_UNITS = mm +ANGULAR_UNITS = degree + +[JOINT_0] +MAX_VELOCITY = 1.0 +MAX_VELOCITY = 2.0