mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
Snapd installs bash completion files from snaps in `/usr/share/bash-completion/completions` which in some distributions is a read-only filesystem. Instead of installing them in `/usr` we can install them within `/var/lib/snapd` which should always be writable. Because `/var/lib/snapd/desktop` is already in `XDG_DATA_DIRS`, we can save the files there. Because bash-completion 2.1 and prior do not support `XDG_DATA_DIRS`, on older distributions, the legacy path `/usr/share/bash-completion/completions` will still be used.
71 lines
1.2 KiB
Tcl
71 lines
1.2 KiB
Tcl
# -*- tcl -*-
|
||
|
||
set send_slow {1 0.001}
|
||
set timeout 30
|
||
|
||
proc delay {} {
|
||
sleep 0.5
|
||
}
|
||
|
||
proc chat {outstr instr {keep false}} {
|
||
send -s $outstr
|
||
delay
|
||
if $keep {
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
-notransfer $instr
|
||
}
|
||
} else {
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
$instr
|
||
}
|
||
}
|
||
}
|
||
|
||
proc rechat {outstr inre {keep false}} {
|
||
send -s $outstr
|
||
delay
|
||
if $keep {
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
-notransfer -re $inre
|
||
}
|
||
} else {
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
-re $inre
|
||
}
|
||
}
|
||
}
|
||
|
||
proc next {} {
|
||
delay
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
{bash-*[$#] $}
|
||
}
|
||
}
|
||
|
||
proc cancel {} {
|
||
send -s "\r"
|
||
next
|
||
}
|
||
|
||
proc brexit {} {
|
||
send -s "exit\r"
|
||
expect {
|
||
timeout {puts "timeout"; exit 1}
|
||
eof {exit 0}
|
||
}
|
||
}
|
||
|
||
|
||
# Set up and ensure we have an empty environment as on some systems
|
||
# (debian) PS1 leaks into the newly spawned shell which causes our
|
||
# tests to fail.
|
||
spawn env -u PS1 bash --norc -i
|
||
next
|
||
send ". /usr/share/bash-completion/bash_completion; . ../../../data/completion/bash/snap\n"
|
||
next
|