* [OSS-Tools] [PATCH microcom] main: error out on positional arguments
@ 2025-01-04 15:17 Jonas Rebmann
0 siblings, 0 replies; only message in thread
From: Jonas Rebmann @ 2025-01-04 15:17 UTC (permalink / raw)
To: oss-tools; +Cc: Jonas Rebmann
As microcom makes no use of positional arguments, error out and show
usage if a positional argument is presented.
Without this patch, invalid usage involving a positional such as
microcom /dev/ttyUSB0 is silently ignored.
Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
microcom.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/microcom.c b/microcom.c
index 2b3d484..974c0cf 100644
--- a/microcom.c
+++ b/microcom.c
@@ -183,6 +183,10 @@ int main(int argc, char *argv[])
}
}
+ if (optind < argc) {
+ main_usage(1, "", "");
+ }
+
if (answerback) {
ret = asprintf(&answerback, "%s\n", answerback);
if (ret < 0)
--
2.39.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-04 15:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-04 15:17 [OSS-Tools] [PATCH microcom] main: error out on positional arguments Jonas Rebmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox