이러한 bash 완료 제안은 어떤 관련이 있습니까?

이러한 bash 완료 제안은 어떤 관련이 있습니까?

~$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

분명히 <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

thing은 표시된 항목으로 표시됩니다 ~<TAB><TAB>. 디렉터리를 가리 points-atthing거나 존재하지 않는 위치를 가리킵니다 thing.

예를 들어, ~cat주어진 bash: /home/cat: Is a directory, 그래서 ~cat -> /home/cat그러나 ~clickpkg주어진 bash: /nonexistent: No such file or directory, 그래서 ~clickpkg -> ENOENT /nonexistent/.

나는 내가 가진 모든 데이터를 제공했습니다. 여기서 무슨 일이 일어나고 있는 걸까요? ~비밀이 뭔가로 확장된 것은 아닐까 ?

답변1

A는 사용자의 디렉터리 ~user입니다 . 이는 다음 모든 디렉토리 목록(두 번째 열) $HOME에 의해 향상됩니다 .
~

awk -F ":" '{printf( "%15s \t %-20s\n",$1,$6)}' /etc/passwd

man bash에서 ("물결표 확장" 검색)

물결표 확장
물결표 접두사에 인용 부호가 없는 문자가 있는 경우 물결표 접두사에서 물결표 뒤에 오는 문자는 가능한 로그인 이름으로 처리됩니다.
...물결표 접두사는 지정된 로그인과 연결된 홈 디렉터리로 대체됩니다.

관련 정보