Skip to content

Conversation

@hnez
Copy link
Member

@hnez hnez commented Nov 6, 2025

Looks like I have shot myself in the foot again with a shell script.


Prior to this patch the part of the hook script that handles migration of user-specified files will fail if the /etc/rauc/migrate.d directory exists but does not contain any *.conf files.

Make sure that the glob expands to nothing instead of the string /etc/rauc/migrate.d/*.conf in this case by setting the nullglob option. This also removes the need for the ineffective check for the existance of the /etc/rauc/migrate.d directory.

@michaelolbrich
Copy link
Collaborator

This will also affect other path expansions in the same script. There are other loops that will no longer fail the the given pattern matches no files.
If that is ok then the commit message should include that. Otherwise, enable and disable nullglob just for this one loop.

@rohieb
Copy link
Contributor

rohieb commented Nov 7, 2025

As an alternative, you could also test if $(ls "${EXTRA_MIGRATE_LISTS_DIR}"/*.conf) is empty before for-looping over it.

@hnez
Copy link
Member Author

hnez commented Nov 11, 2025

This will also affect other path expansions in the same script. There are other loops that will no longer fail the the given pattern matches no files. If that is ok then the commit message should include that.

I have checked the other loop and I think the behavior with nullglob matches my intent, that I had when I initially wrote the loop, better. I have added a comment about it to the commit message.

I actually find the default behavior quite surprising (not in a good way).

@michaelolbrich
Copy link
Collaborator

I actually find the default behavior quite surprising (not in a good way).

It depends on the use-case. The default uncovers typos if the glob is supposed to always match something.
But in the end, the choice was made a long time ago and changing it now would break a lot of scripts now.

… dir

Prior to this patch the part of the hook script that handles migration of
user-specified files will fail if the `/etc/rauc/migrate.d` directory
exists but does not contain any `*.conf` files.

Make sure that the glob expands to nothing instead of the string
`/etc/rauc/migrate.d/*.conf` in this case by setting the `nullglob`
option. This also removes the need for the ineffective check for the
existance of the `/etc/rauc/migrate.d` directory.

This also affects the other for loop with a glob, which searches for
available certificate files. The behaviour of this loop also matches the
expected behaviour better with the `nullglob` option enabled.

Signed-off-by: Leonard Göhrs <[email protected]>
@hnez
Copy link
Member Author

hnez commented Nov 13, 2025

Hi, I would like to get this merged. @michaelolbrich should I change anything or could you give me an approval?

Copy link
Collaborator

@michaelolbrich michaelolbrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the updated commit message, it looks good to me.

@hnez hnez merged commit aca7179 into linux-automation:walnascar Nov 21, 2025
5 checks passed
@hnez hnez deleted the empty-migrate-d branch November 21, 2025 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants