Avoid unnecessary which and fix typos

This commit is contained in:
pagedown
2022-03-07 11:30:12 +08:00
parent 3095e7a256
commit 397fbe7ad3
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_from_globs(*pats: str) -> Callable[[tarfile.TarInfo], Optional[tarfile.TarInfo]]:
def filter(tarinfo: tarfile.TarInfo) -> Optional[tarfile.TarInfo]: def filter(tarinfo: tarfile.TarInfo) -> Optional[tarfile.TarInfo]:
for junk_dir in ('.DS_Store', '__pycache__'): 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): if fnmatch.fnmatch(tarinfo.name, pat):
return None return None
for pat in pats: for pat in pats:

View File

@@ -103,21 +103,20 @@ def move(src, base_dest):
def compile_terminfo(base): def compile_terminfo(base):
if not shutil.which('tic'): tic = shutil.which('tic')
if not tic:
return return
tname = '.terminfo' tname = '.terminfo'
if os.path.exists('/usr/share/misc/terminfo.cdb'): if os.path.exists('/usr/share/misc/terminfo.cdb'):
tname += '.cdb' tname += '.cdb'
os.environ['TERMINFO'] = os.path.join(HOME, tname) os.environ['TERMINFO'] = os.path.join(HOME, tname)
tic = shutil.which('tic') cp = subprocess.run(
if tic: [tic, '-x', '-o', os.path.join(base, tname), os.path.join(base, '.terminfo', 'kitty.terminfo')],
cp = subprocess.run( stdout=subprocess.PIPE, stderr=subprocess.STDOUT
[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)
if cp.returncode != 0: raise SystemExit('Failed to compile the terminfo database')
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
def get_data(): def get_data():
@@ -176,8 +175,8 @@ def exec_zsh_with_integration():
os.environ.pop('KITTY_ORIG_ZDOTDIR', None) # ensure this is not propagated os.environ.pop('KITTY_ORIG_ZDOTDIR', None) # ensure this is not propagated
else: else:
os.environ['KITTY_ORIG_ZDOTDIR'] = zdotdir os.environ['KITTY_ORIG_ZDOTDIR'] = zdotdir
# dont prevent zsh-new-user from running # dont prevent zsh-newuser-install from running
for q in '.zshrc .zshenv .zprofile .zlogin'.split(): for q in ('.zshrc', '.zshenv', '.zprofile', '.zlogin'):
if os.path.exists(os.path.join(HOME, q)): if os.path.exists(os.path.join(HOME, q)):
os.environ['ZDOTDIR'] = shell_integration_dir + '/zsh' os.environ['ZDOTDIR'] = shell_integration_dir + '/zsh'
os.execlp(login_shell, os.path.basename(login_shell), '-l') 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 # ask for the SSH data
leading_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"" [ "$tty_ok" = "y" ] && dcs_to_kitty "ssh" "id="REQUEST_ID":hostname="$hostname":pwfile="PASSWORD_FILENAME":user="$USER":pw="DATA_PASSWORD""
record_separator=$(printf "\036") record_separator=$(printf "\036")
@@ -287,7 +287,7 @@ exec_zsh_with_integration() {
else else
export KITTY_ORIG_ZDOTDIR="$zdotdir" export KITTY_ORIG_ZDOTDIR="$zdotdir"
fi 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 if [ -f "$zdotdir/.zshrc" -o -f "$zdotdir/.zshenv" -o -f "$zdotdir/.zprofile" -o -f "$zdotdir/.zlogin" ]; then
export ZDOTDIR="$shell_integration_dir/zsh" export ZDOTDIR="$shell_integration_dir/zsh"
exec "$login_shell" "-l" exec "$login_shell" "-l"