~
é $HOME
. Para mim, cd ~
é /home/cat
. Simples até agora, sim?
No Bash, acontece o seguinte:
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
Obviamente, <TAB>
representa a tecla TAB enviando o byte em ASCII 9
, não aquele texto real.
Eu deixei no meu aviso PS1
para mostrar o caminho atual e os códigos de retorno. Minha pergunta é: qual é a relevância desses diretórios serem preenchidos automaticamente a partir de ~
?
Eu criei uma tabela dessas e de onde elas apontam, para melhor entendê-las (mas estou mais confuso agora).
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
A coluna thing
é a entrada mostrada por ~<TAB><TAB>
. points-at
é o diretório thing
aponta para ou o local inexistente para o qual thing
aponta.
Por exemplo, ~cat
dá bash: /home/cat: Is a directory
, então ~cat -> /home/cat
mas ~clickpkg
dá bash: /nonexistent: No such file or directory
, então ~clickpkg -> ENOENT /nonexistent/
.
Eu apresentei todos os dados que tenho. Oque esta acontecendo aqui? O ~
está sendo secretamente expandido para algo?