short command not working

12 views
Skip to first unread message

Mani Amoozadeh

unread,
Jan 2, 2026, 12:38:09 AMJan 2
to klish
In lates klish (3.2), I have something like this:

        <COMMAND name="his|tory" help="Display command history">
            <ACTION sym="script">
                if [ -f /tmp/klish_history.log ]; then
                    # 'nl' adds line numbers, -w3 sets width, -s sets separator
                    nl -w3 -s"  " /tmp/klish_history.log
                else
                    echo "No history available."
                fi
            </ACTION>
        </COMMAND>

But

NetLab# his
Error: Illegal command

NetLab# history
Error: Illegal command

NetLab# his|tory
<output>

Serj Kalichev

unread,
Jan 12, 2026, 9:59:08 AMJan 12
to kl...@googlegroups.com
Hi

You need "value" attribute to set short commands. The "name" attribute can't contain special characters because it's used for the addressable scheme elements so the "name"'s value is a part of "path". It can be used for COMMAND "ref"erences  for example.

So use <COMMAND name="history" value="his|tory"/>

I have updated documentation for the "COMMAND" ptype:

```

Symbol COMMAND

The COMMAND symbol checks that the entered argument matches the command name. That is, with the name or value attributes of the COMMAND or PARAM elements. If the value attribute is set, its value is used as the command name. If not set, the value of the name attribute is used. The case of characters in the command name is not taken into account.

Sometimes it’s convenient to have shortcuts for commands so you don’t have to type the full names. For example, for a command with the full name environment, you can define allowed abbreviations, and then entering env will be enough to invoke it. To define allowed abbreviations, the value attribute is used (it won’t work with the name attribute). In the attribute’s value, the mandatory prefix of the command is separated by the | symbol from the optional part. For example:

<COMMAND name="environment" value="env|ironment" />

For such a command, you can use abbreviations like env, envi, envir, and so on. However, strings like e and en won’t work because they are shorter than the minimum required prefix env.

```


--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/klish/85d93382-a338-415d-80b9-719118b35e5fn%40googlegroups.com.


Reply all
Reply to author
Forward
0 new messages