[mej/nhc] 5308da: nhc-wrapper: Allow wrapping of non-system items

3 views
Skip to first unread message

Michael Jennings

unread,
Jan 11, 2023, 8:35:50 PM1/11/23
to nhc-...@lbl.gov
Branch: refs/heads/dev
Home: https://github.com/mej/nhc
Commit: 5308da46792cf075057ea78430b4b0c761fce7ae
https://github.com/mej/nhc/commit/5308da46792cf075057ea78430b4b0c761fce7ae
Author: Michael Jennings <m...@lanl.gov>
Date: 2023-01-11 (Wed, 11 Jan 2023)

Changed paths:
M nhc-wrapper

Log Message:
-----------
nhc-wrapper: Allow wrapping of non-system items

The intent was always to allow `nhc-wrapper` to be used for any
arbitrary command, either a system command the user has permission to
run or a custom utility in the same location as the `*-wrapper` link.
This can be seen in the old `nhcwrap_finalize_env()` attempting to
extract the `dirname` and `basename` of `$SUBPROG`.

However, that never worked; the value of `$0` was already split into
`dirname`/`basename` in `nhcwrap_init_env()`...and the former was
discarded completely. Only the `basename` portion was saved to
`$SUBPROG`.

This fixes the problem by saving both halves of the split value in
`nhcwrap_init_env()` and prepending the `dirname` part to `$PATH`.
After parsing the command line, in case the (undocumented) `-P` option
was provided, `nhcwrap_finalize_env()` checks `$SUBPROG` against the
original `$0`, and if `$SUBPROG` has been altered, it repeats the
above actions with the new value.


Reply all
Reply to author
Forward
0 new messages