pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sysutils/sysupgrade: Wrong shell used --> wipes local changes to /etc



    Date:        Thu, 19 Nov 2026 15:20:59 +0100
    From:        Matti Andreas =?utf-8?B?S8OkaMOkcmk=?= <andreas.kahari%abc.se@localhost>
    Message-ID:  <av8Fy2psCDWfIEk3@eeyore.invalid>

  | Here's the relevant code:
  |
  | 	355     for set_name in "${@:-$(shtk_config_get SETS)}"; do

  | When "$@" is empty (which it will be if running either "sysupgrade sets"
  | with no extra arguments, or "sysupgrade auto"), the sh shell will expand
  | the quoted expression "$(shtk_config_get SETS)" into a list of set
  | names,

Ugh, so we do - that's a bug which I will fix soon, now that I know
about it.

  | while the mksh shell will not split it.

Nor will any other shell I can find.   The magic "$@" processing is
for "$@" alone, not for some other value substituted when "$@" is empty.

  | Any input is welcomed.

That code needs to be rewritten.

A very rough alternative would be

test [ "$#" -eq 0 ] && set -- $(shtk_config_get SETS)
for set_name
do

but that doesn't protect the output of shtk_config_get if it
were to contain white space (which I guess the way it is written now
kind of assumes that won't be needed) or other sh meta chars (* ? ...)
Handling that requires

test [ "$#" -eq 0 ] && eval set -- $(shtk_config_get -q SETS)

assuming a (probably non-existant) -q option which would quote the names
returned (each of them separately), or somehow equivalent code (which would
be likely to have the same problem - once emitted unquoted, it is hard to be
sure where the quotes should be inserted).

kre



Home | Main Index | Thread Index | Old Index