Shell Huh #?

I deal with routers/switches a lot. It's second nature to utilize the question mark to get a list of commands, like so:

Code:
Router# ?
command     This is a command
help        Displays help info
...etc
It would be useful if this were implemented in some way with default shell aliases. I prefer bash so in my /etc/skel/.bashrc (or .bash_profile) script, there's this line:
alias ?='cat /etc/motd; alias'

My motd happens to list custom commands and usage, like in the above example. However, my recommendations for default, built-in usage, would include displaying commands (and basic usage) of several admin and process related tasks, like:
man apropos whoami df mount pkg
portmaster (a lead-in to using/installing ports since it's not a default installation)
sudo (ditto)
freebsd-update
netstat ifconfig top tar gzip

..or even subject matter like:
FreeBSD
System configuration
Ports
Initial administration, setup, and security
Networking
Filesystem

Etc. It would also be useful to further implement some basic follow-up commands, like say how popular databases and languages allow for "help command subcommand", which could give the new user some depth to work with.

These are a few ideas that play on the original. In the KISS principle, just a '?' would be great for starters. Maybe even for some seasoned admins too!
 
Contextually, yes. However, and maybe it's because I only use bash as my shell, by itself the ? character is usable as a file name.

Code:
[root@sigma ~]# ?
su: ?: command not found

When assigned to an alias:

Code:
[root@sigma ~]# alias
...
alias ?='cat /etc/motd; alias'
...

The result looks like this.

Code:
[root@sigma ~]# ?
FreeBSD 10.3-RELEASE-p7 (GENERIC) #0: Thu Aug 11 18:38:15 UTC 2016
...

Should I assume by your response, SirDice, or others whom share the same idea, that I'm essentially breaking some POSIX/UNIX/other rule|specification by assigning ? to a functional command?
 
I'm wondering what happens with the alias in something like rm ?blah. Which would come first? The alias or the shell glob?
 
Back
Top