cat*_*cat 5 bash autocomplete directory-structure
~是$HOME。对我来说,cd ~是/home/cat。到目前为止很简单,是吗?
在 Bash 中,会发生以下情况:
cat @ mint-kitty : ~/Downloads $ cd ~ # from /home/cat/Downloads to /home/cat/, as an example, but behaviour happens with any directory
cat @ mint-kitty : ~ $ cd ~<TAB>proxy/ # oh? what's this?
cat @ mint-kitty : /bin $ cd ~<TAB><TAB>
~ais ~clamav/ ~debian-tor/ ~gitlog ~list ~mixmaster/ ~ntp ~redis/ ~stunnel4 ~systemd-resolve ~uuidd/
~avahi/ ~cl-builder/ ~dirmngr/ ~gnats ~lp ~monkeysphere/ ~oident/ ~roard/ ~sync/ ~systemd-timesync/ ~vde2-net
~avahi-autoipd/ ~clickpkg ~dnsmasq/ ~irc ~mail/ ~mpd/ ~pdnsd/ ~root/ ~syncache/ ~timidity/ ~whoopsie
~backup/ ~colord/ ~epmd ~jetty/ ~man/ ~muroard/ ~postgres/ ~rtkit/ ~sys/ ~tomcat8 ~www-data/
~bin/ ~daemon/ ~festival ~libvirt-dnsmasq/ ~mdm/ ~mysql ~proxy/ ~saned ~syslog ~trafficserver
~bind/ ~Debian-exim/ ~games/ ~libvirt-qemu/ ~memcache ~news ~pulse ~speech-dispatcher ~systemd-bus-proxy/ ~uml-net
~cat/ ~debian-spamd/ ~gitdaemon ~lightdm/ ~messagebus/ ~nobody ~radvd ~sshd/ ~systemd-network ~uucp
cat @ mint-kitty : /bin $ cd ~systemd-resolve
bash: cd: /run/systemd/resolve: No such file or directory
1 | cat @ mint-kitty : /bin $ cd ~redis
cat @ mint-kitty : /var/lib/redis $ cd ~clamav
cat @ mint-kitty : /var/lib/clamav $ cd ~irc
bash: cd: /var/run/ircd: No such file or directory
1 | cat @ mint-kitty : /var/lib/clamav $ cd ~gnats
bash: cd: /var/lib/gnats: No such file or directory
1 | cat @ mint-kitty : /var/lib/clamav $ cd ~sshd
cat @ mint-kitty : /var/run/sshd $ cd ~nobody
bash: cd: /nonexistent: No such file or directory
Run Code Online (Sandbox Code Playgroud)
显然,<TAB>代表 TAB 键以 ASCII 发送字节9,而不是实际文本。
我已经在PS1提示中显示当前路径和返回代码。我的问题是,从这些目录自动完成的相关性是什么~?
我已经创建了一个表格,其中包含这些内容及其指向的位置,以更好地理解它们(但我现在更困惑了)。
thing points-at?
===========================================
~ais ENOENT /home/ais/ # user ais uid=156(ais) gid=163(ais) groups=163(ais) does not have an entry in /home/
~avahi /var/run/avahi-daemon/
~avahi-autoipd /var/lib/avahi-autoipd/
~backup /var/backups/
~bin /bin/
~bind /var/cache/bind/
~cat /home/cat/
~clamav /var/lib/clamav/
~cl-builder /usr/share/common-lisp// # two slashes
~clickpkg ENOENT /nonexsistent/ # yes, really
~colord /var/lib/colord/
~daemon /usr/sbin/ # ??
~Debian-exim /var/spool/exim4/ # ??
~debian-spamd /var/lib/spamassassin/
~debian-tor /var/lib/tor/
~dirmngr /var/cache/dirmngr/
~dnsmasq /var/lib/misc/ # ??
~epmd /var/run/epmd/
~festival ENOENT /home/festival # user festival uid=131(festival) gid=29(audio) groups=29(audio) does not have an entry in /home/
~games /usr/games/ # ???
~gitdaemon ENOENT /nonexistent/
~gitlog ENOENT /nonexistent/
~gnats /var/lib/ircd/
~jetty /usr/share/jetty8/
~libvirt-dnsmasq /var/lib/libvirt/
~libvirt-qemu /var/lib/libvirt/
~lightdm /var/lib/lightdm/
~list ENOENT /var/list/
~lp ENOENT /var/spool/lpd/
~mail /var/mail/
~man /var/cache/man/
~mdm /var/lib/mdm/
~memcache ENOENT /nonexistent/
~messagebus /var/run/dbus
~mixmaster /var/lib/mixmaster/
~monkeysphere /var/lib/monkeysphere/
~mpd /var/lib/mpd/
~muroard /var/lib/muroard/
~mysql ENOENT /nonexistent/
~nobody ENOENT /nonexistent/
~ntp ENOENT /home/ntp # user ntp uid=107(ntp) gid=114(ntp) groups=114(ntp) does not have an entry in /home/
~oident / # ????
~pdnsd /var/cache/pdnsd/
~postgres /var/lib/postgresql/
~proxy /bin/
~pulse ENOENT /var/run/pulse
~radvd ENOENT /var/run/radvd
~redis /var/lib/redis
~roard /var/lib/roard
~root /root
~rtkit /proc
~saned ENOENT /var/lib/saned
~speech-dispatcher ENOENT /var/run/speech-dispatcher
~sshd /var/run/sshd
~stunnel4 ENOENT /var/run/stunnel4
~sync /bin/
~syncache /var/run/syncache-drb/
~sys /dev/ # ???
~syslog ENOENT /home/syslog # user syslog uid=104(syslog) gid=109(syslog) groups=109(syslog),4(adm) does not have an entry in /home/
~systemd-bus-proxy /run/systemd/
~systemd-network ENOENT /run/systemd/netif/
~systemd-resolve ENOENT /run/systemd/resolve/
~systemd-timesync /run/systemd/
~timidity /etc/timidity/
~tomcat8 ENOENT /usr/share/tomcat8/
~trafficserver ENOENT /var/run/trafficserver/
~uml-net ENOENT /home/uml-net/ # user uml-net uid=146(uml-net) gid=155(uml-net) groups=155(uml-net) does not have an entry in /home/
~uucp ENOENT /var/spool/uucp/
~uuidd /run/uuidd/
~vde2-net ENOENT /var/run/vde2/
~whoospie ENOENT /nonexistent/
~www-data /var/www
Run Code Online (Sandbox Code Playgroud)
该thing列是由 显示的条目~<TAB><TAB>。points-at要么是目录thing指向,要么是不存在的地方thing指向。
例如,~cat给出bash: /home/cat: Is a directory,所以,~cat -> /home/cat但是~clickpkg给出bash: /nonexistent: No such file or directory,所以~clickpkg -> ENOENT /nonexistent/。
我已经展示了我得到的所有数据。这里发生了什么?是~被偷偷扩大到什么地方吗?
小智 5
A~user是该$HOME用户的目录。
这是~所有这些(第二列)增加的目录列表:
awk -F ":" '{printf( "%15s \t %-20s\n",$1,$6)}' /etc/passwd
Run Code Online (Sandbox Code Playgroud)
来自 man bash(搜索“波浪号扩展”)
波浪号扩展如果波浪号前缀中的任何字符都没有被引用,则波浪号后面的波浪号前缀中的字符将被视为可能的登录名。
... 波浪号前缀被替换为与指定登录名关联的主目录。