diff --git a/docs/src/man/man1/halcmd.1.adoc b/docs/src/man/man1/halcmd.1.adoc index 82a8b2369f5..a8baf1d5162 100644 --- a/docs/src/man/man1/halcmd.1.adoc +++ b/docs/src/man/man1/halcmd.1.adoc @@ -144,7 +144,10 @@ requested component with a call to *dlopen(3)*. _arrow_ can be "`=>`", "`<=`", "`<=>`", or omitted. *halcmd* ignores arrows, but they can be useful in command files to document the direction of data flow. Arrows should not be used on the command line - since the shell might try to interpret them. Fails if either _pinname_ + since the shell might try to interpret them. An arrow is only an arrow + when spaces separate it from the names: "`lube-pump=>`" is a signal + name, and *halcmd* warns about a name that starts or ends with an + arrow. Fails if either _pinname_ or _signame_ does not exist, or if they are not the same type type. *linksp* _signame_ [_arrow_] _pinname_:: (OBSOLETE - use *net* instead) (_link_ __s__ignal to __p__in) Works diff --git a/src/hal/utils/halcmd.c b/src/hal/utils/halcmd.c index 694801c8d0a..d27824ad053 100644 --- a/src/hal/utils/halcmd.c +++ b/src/hal/utils/halcmd.c @@ -303,6 +303,14 @@ static int count_args(const char **argv) { return i; } +/* "lube-pump=>" or "=>io.relay": an arrow written without a space */ +static int has_attached_arrow(const char *arg) { + size_t len = strlen(arg); + if(len < 3) return 0; + return !strncmp(arg, "<=", 2) || !strncmp(arg, "=>", 2) || + !strcmp(arg + len - 2, "<=") || !strcmp(arg + len - 2, "=>"); +} + #define ARG(i) (argc > i ? argv[i] : NULL) #define REST(i) (argc > i ? argv + i : argv + argc) @@ -338,6 +346,10 @@ static int parse_cmd1(const char **argv) { !strcmp(argv[s], "<=>")) { continue; } else { + if(has_attached_arrow(argv[s])) + halcmd_warning("'%s' has an arrow attached, it is taken" + " as part of the name; put a space between the name" + " and the arrow\n", argv[s]); argv[d++] = argv[s]; } } diff --git a/src/hal/utils/halcmd_commands.cc b/src/hal/utils/halcmd_commands.cc index 35241919828..3252cb920e0 100644 --- a/src/hal/utils/halcmd_commands.cc +++ b/src/hal/utils/halcmd_commands.cc @@ -2517,7 +2517,7 @@ int do_help_cmd(const char *command) printf("linksp signame [arrow] pinname\n"); printf(" Links pin 'pinname' to signal 'signame'. Both forms do\n"); printf(" the same thing. Use whichever makes sense. The optional\n"); - printf(" 'arrow' can be '==>', '<==', or '<=>' and is ignored. It\n"); + printf(" 'arrow' can be '=>', '<=', or '<=>' and is ignored. It\n"); printf(" can be used in files to show the direction of data flow,\n"); printf(" but don't use arrows on the command line.\n"); } else if(strcmp(command, "net") == 0) {