Give the path some breathing room
Some Maximo command-line tools expect an option and its value to arrive as a single argument:
./mxdiff.sh -m/tmp/input.xmlThat is awkward when you want the shell to complete the path. What I want to type is:
./mxdiff.sh -m /tmp/input.xmlA small adapter can join those two arguments before the tool sees them. The Java code still receives -m/tmp/input.xml, while we get to put the path in its own shell word and use normal filename completion.
One less thing to type. Maximo will find something else for us to do with the time.
Download the adapter
Download maximo-spaced-args.sh and save it alongside the launcher you want to adapt. If your browser displays it as text, use Save link as and retain the .sh filename.
The usage notes and test script are available too. These are standalone helper files; they do not contain IBM's tools or application code.
The adapter requires Bash. It can be sourced by a Bash launcher or run as a separate wrapper around an existing command.
One injection for legacy option/value pairs
Use automatic mode to avoid maintaining a separate option list for every launcher:
maximo_normalize_args auto "$@"It joins any single-dash option name made of letters, digits and hyphens, beginning with a letter, to the next non-empty argument that does not begin with a dash. This covers options such as -m, -o, -Q and -mt without naming them in the helper. Adjacent switches and a final switch pass through unchanged.
Automatic mode cannot infer every tool's argument grammar. For example, -v file.xml could be a boolean switch followed by a positional filename, or an option taking a filename. Automatic mode joins it. Likewise, it cannot tell whether -tMAXDATA is an option name or an already-attached value; if another plain argument follows, it joins that too.
Use this mode for tools whose arguments follow the legacy option/value convention. Where a tool mixes boolean switches and positional values, use the explicit option-list mode described below. A completely reliable adapter for all tools would need their argument definitions; shell tokens alone do not contain that information.
Add it to a Bash launcher
Make a copy of your launcher before editing it. Change its shebang to Bash if necessary, then add this block before any existing code that reads or shifts the command-line arguments:
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) || exit 1
source "$SCRIPT_DIR/maximo-spaced-args.sh" || exit "$?"
maximo_normalize_args auto "$@" || exit "$?"
set -- "${MAXIMO_NORMALIZED_ARGS[@]}"The function places the converted arguments in a Bash array. set -- then replaces the launcher's positional arguments with that array, preserving each argument as a separate value.
Keep the rest of the launcher's environment setup and Java command, but check how it forwards arguments. The final invocation should pass them using quoted "$@":
"$JAVA" -classpath "$CLASSPATH" your.existing.JavaClass "$@"That is an illustration, not a replacement Java command. Retain your actual executable, JVM options, classpath and class name.
An unquoted $*, $@ or list such as $1 $2 $3 $4 can split a filename containing spaces and expand wildcard characters. Some older launchers also shift arguments into separate variables before invoking Java. Those need their argument-forwarding logic adapted too; adding the helper cannot undo splitting that happens afterwards.
Run your modified launcher directly, or use bash mxdiff.sh. Running sh mxdiff.sh bypasses its Bash shebang and will not support the adapter's arrays.
Use the spaced form
With the integration in place, all three forms below reach the tool with an attached -m value:
./mxdiff.sh -m /tmp/input.xml
./mxdiff.sh -m "/tmp/my input.xml"
./mxdiff.sh -m/tmp/input.xmlFor path completion, type ./mxdiff.sh -m /tmp/ and press Tab. The helper changes argument handling, not your shell's completion configuration; any command-specific completion rules still apply.
The space between an option and its value and the spaces inside a filename are separate concerns. The first is what the adapter converts. The second still requires shell quoting or escaping, and the underlying Java tool must accept that filename.
Use it as a wrapper instead
If your existing launcher already forwards arguments correctly, you can leave it unchanged:
bash /path/to/maximo-spaced-args.sh auto ./mxdiff.sh -m /tmp/input.xmlThe first argument selects automatic mode, the second is the command to launch, and everything after that is passed to the command after conversion. Run from whichever working directory your original launcher expects.
The wrapper uses exec, so the command retains its standard input/output and exit status. Bash is required for the adapter; the wrapped launcher can use another shell.
This approach still depends on that launcher preserving arguments. If it later expands them unquoted, fix the forwarding or inject the helper into a launcher you control.
What automatic mode converts
| Input | Result |
|---|---|
-m /tmp/input.xml |
-m/tmp/input.xml |
-z "/tmp/my input.xml" |
One argument: -z/tmp/my input.xml |
-mt value |
-mtvalue |
-m/tmp/input.xml |
Unchanged |
-v -m /tmp/input.xml |
-v followed by -m/tmp/input.xml |
-v input.xml |
-vinput.xml; ambiguous if -v is boolean |
-m |
Unchanged; the tool decides whether a value is required |
-m "" |
Two unchanged arguments |
-n -1 |
Two unchanged arguments; use -n-1 for an attached negative value |
--output file.xml |
Two unchanged arguments; double-dash options are not converted |
For a dash-leading filename, use a path such as -m ./-input.xml. A -- argument stops conversion and is forwarded unchanged; the underlying tool must support it too.
The implementation uses quoted array elements, not eval or a reconstructed command string. Shell metacharacters inside a quoted value remain data. This preserves shell argument boundaries but does not change how the Java tool subsequently parses them.
Explicit mode for ambiguous tools
For a tool that mixes boolean switches, positional values or already-attached word values, supply its value-taking options instead of auto:
maximo_normalize_args '-m -o' "$@" || exit "$?"
set -- "${MAXIMO_NORMALIZED_ARGS[@]}"Only exact, case-sensitive matches consume a value. Everything else passes through unchanged, including attached values. Missing, empty or dash-leading separate values return status 2 in this mode. Confirm the options from the tool's help and omit boolean switches.
Check the integration before running the real tool
Save the test script beside the helper and run:
bash test.shThe tests cover spaced and attached values, quoted filenames, literal metacharacters, boolean and unknown switches, repeated options, missing values, wrapper exit status and an injected launcher. They do not run Maximo or connect to a database.
For a quick look at the arguments after normalization, temporarily print them immediately after the set -- line in your launcher and exit before Java runs:
printf 'Argument: <%s>\n' "$@"
exit 0Using -m "/tmp/my input.xml" should print a single line:
Argument: <-m/tmp/my input.xml>Use harmless sample values for this check; argument output can expose passwords if you include them. Remove the temporary print and exit when finished, then test your actual tool with disposable input files.
Keep the helper and launcher change together in version control. Generated IBM scripts can be replaced during an update, so recheck the integration after upgrading the SMP.