[Rpm-maint] [rpm-software-management/rpm] RFE: Command to check if rcfile or macros file syntax is correct (#1796)
Markus Linnala
notifications at github.com
Sat Oct 16 10:26:19 UTC 2021
Like rpm --showrc but with exit code 0 if there was no errors. Otherwise exit with 1.
This could be used in automation pipelines to check early if there is something wrong with a file.
```|sh
$ rpm --rcfile='' --macros=/bin/bash --showrc > /dev/null
error: /bin/bash: line 344: Macro % has illegal name (%define)
error: /bin/bash: line 2885: Macro %s has illegal name (%define)
error: /bin/bash: line 2993: Macro %b has illegal name (%define)
error: /bin/bash: line 2994: Macro %q has illegal name (%define)
error: /bin/bash: line 2995: Macro % has illegal name (%define)
error: /bin/bash: line 4300: Macro %2d has illegal name (%define)
$ echo $?
0
$ rpm --rcfile=/bin/bash --macros='' --showrc > /dev/null
error: missing ':' (found 0x00) at /bin/bash:1
$ echo $?
0
```
My currently best way to do this is to check if stderr has error: string. But that is not very convenient compared just to checking command exit code.
```|sh
$ ! rpm --rcfile='' --macros=/bin/bash --showrc 2>&1 > /dev/null | grep -q '^error: '
$ echo $?
1
$ ! rpm --rcfile=/bin/bash --macros='' --showrc 2>&1 > /dev/null | grep -q '^error: '
$ echo $?
1
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/1796
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20211016/09cf3b4d/attachment.html>
More information about the Rpm-maint
mailing list