Avoid unnecessary which and fix typos

This commit is contained in:
pagedown 2022-03-07 11:30:12 +08:00
parent 3095e7a256
commit 397fbe7ad3
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
3 changed files with 14 additions and 15 deletions

View File

@ -73,7 +73,7 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str]) -> bytes:
def filter_from_globs(*pats: str) -> Callable[[tarfile.TarInfo], Optional[tarfile.TarInfo]]:
def filter(tarinfo: tarfile.TarInfo) -> Optional[tarfile.TarInfo]:
for junk_dir in ('.DS_Store', '__pycache__'):
for pat in (f'*/{junk_dir}', '*/{junk_dir}/*'):
for pat in (f'*/{junk_dir}', f'*/{junk_dir}/*'):
if fnmatch.fnmatch(tarinfo.name, pat):
return None
for pat in pats:

View File

@ -103,21 +103,20 @@ def move(src, base_dest):
def compile_terminfo(base):
if not shutil.which('tic'):
tic = shutil.which('tic')
if not tic:
return
tname = '.terminfo'
if os.path.exists('/usr/share/misc/terminfo.cdb'):
tname += '.cdb'
os.environ['TERMINFO'] = os.path.join(HOME, tname)
tic = shutil.which('tic')
if tic:
cp = subprocess.run(
[tic, '-x', '-o', os.path.join(base, tname), os.path.join(base, '.terminfo', 'kitty.terminfo')],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
if cp.returncode != 0:
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
cp = subprocess.run(
[tic, '-x', '-o', os.path.join(base, tname), os.path.join(base, '.terminfo', 'kitty.terminfo')],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
if cp.returncode != 0:
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
def get_data():
@ -176,8 +175,8 @@ def exec_zsh_with_integration():
os.environ.pop('KITTY_ORIG_ZDOTDIR', None) # ensure this is not propagated
else:
os.environ['KITTY_ORIG_ZDOTDIR'] = zdotdir
# dont prevent zsh-new-user from running
for q in '.zshrc .zshenv .zprofile .zlogin'.split():
# dont prevent zsh-newuser-install from running
for q in ('.zshrc', '.zshenv', '.zprofile', '.zlogin'):
if os.path.exists(os.path.join(HOME, q)):
os.environ['ZDOTDIR'] = shell_integration_dir + '/zsh'
os.execlp(login_shell, os.path.basename(login_shell), '-l')

View File

@ -95,7 +95,7 @@ if [ -z "$USER" ]; then USER=$(command whoami 2> /dev/null); fi
# ask for the SSH data
leading_data=""
init_tty && trap 'cleanup_on_bootstrap_exit' EXIT
init_tty && trap "cleanup_on_bootstrap_exit" EXIT
[ "$tty_ok" = "y" ] && dcs_to_kitty "ssh" "id="REQUEST_ID":hostname="$hostname":pwfile="PASSWORD_FILENAME":user="$USER":pw="DATA_PASSWORD""
record_separator=$(printf "\036")
@ -287,7 +287,7 @@ exec_zsh_with_integration() {
else
export KITTY_ORIG_ZDOTDIR="$zdotdir"
fi
# dont prevent zsh-new-user from running
# dont prevent zsh-newuser-install from running
if [ -f "$zdotdir/.zshrc" -o -f "$zdotdir/.zshenv" -o -f "$zdotdir/.zprofile" -o -f "$zdotdir/.zlogin" ]; then
export ZDOTDIR="$shell_integration_dir/zsh"
exec "$login_shell" "-l"