-
Notifications
You must be signed in to change notification settings - Fork 0
fix(install): skip shell config for uninstalled shells #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -131,35 +131,40 @@ fi | |||||||||||||
| if [ ! -d "$HOME/.shelltime/daemon" ]; then | ||||||||||||||
| mkdir -p "$HOME/.shelltime/daemon" | ||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||
| echo "Error: Failed to create $HOME/.shelltime/daemon directory." | ||||||||||||||
| exit 1 | ||||||||||||||
| echo "Warning: Failed to create $HOME/.shelltime/daemon directory. Daemon functionality may be unavailable." | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Add $HOME/.shelltime/bin to user path | ||||||||||||||
| if [[ "$OS" == "Darwin" ]] || [[ "$OS" == "Linux" ]]; then | ||||||||||||||
| # For Zsh | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.zshrc"; then | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.zshrc" | ||||||||||||||
| echo 'export PATH="$HOME/.shelltime/bin:$PATH"' >> "$HOME/.zshrc" | ||||||||||||||
| if [ -f "$HOME/.zshrc" ]; then | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.zshrc"; then | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.zshrc" | ||||||||||||||
| echo 'export PATH="$HOME/.shelltime/bin:$PATH"' >> "$HOME/.zshrc" | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # For Fish | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.config/fish/config.fish"; then | ||||||||||||||
| if command_exists fish; then | ||||||||||||||
| if [ ! -d "$HOME/.config/fish" ]; then | ||||||||||||||
| mkdir -p "$HOME/.config/fish" | ||||||||||||||
| fi | ||||||||||||||
| if [ ! -f "$HOME/.config/fish/config.fish" ]; then | ||||||||||||||
| touch "$HOME/.config/fish/config.fish" | ||||||||||||||
| fi | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.config/fish/config.fish" | ||||||||||||||
| echo 'fish_add_path $HOME/.shelltime/bin' >> "$HOME/.config/fish/config.fish" | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.config/fish/config.fish"; then | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.config/fish/config.fish" | ||||||||||||||
| echo 'fish_add_path $HOME/.shelltime/bin' >> "$HOME/.config/fish/config.fish" | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # For Bash | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.bashrc"; then | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.bashrc" | ||||||||||||||
| echo 'export PATH="$HOME/.shelltime/bin:$PATH"' >> "$HOME/.bashrc" | ||||||||||||||
| if [ -f "$HOME/.bashrc" ]; then | ||||||||||||||
| if ! grep -q '$HOME/.shelltime/bin' "$HOME/.bashrc"; then | ||||||||||||||
| echo '# Added by shelltime' >> "$HOME/.bashrc" | ||||||||||||||
| echo 'export PATH="$HOME/.shelltime/bin:$PATH"' >> "$HOME/.bashrc" | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -191,8 +196,7 @@ hooks_path="$HOME/.shelltime/hooks" | |||||||||||||
| if [ ! -d "$hooks_path" ]; then | ||||||||||||||
| mkdir -p "$hooks_path" | ||||||||||||||
| if [ $? -ne 0 ]; then | ||||||||||||||
| echo "Error: Failed to create $hooks_path directory." | ||||||||||||||
| exit 1 | ||||||||||||||
| echo "Warning: Failed to create $hooks_path directory. Shell hooks may be unavailable." | ||||||||||||||
| fi | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
|
|
@@ -248,9 +252,15 @@ process_file "bash-preexec.sh" "https://raw.githubusercontent.com/rcaloras/bash- | |||||||||||||
| process_file "bash.bash" "https://raw.githubusercontent.com/malamtime/installation/master/hooks/bash.bash" | ||||||||||||||
|
|
||||||||||||||
| # Add source lines to config files | ||||||||||||||
| add_source_to_config "$HOME/.zshrc" "${hooks_path}/zsh.zsh" | ||||||||||||||
| add_source_to_config "$HOME/.config/fish/config.fish" "${hooks_path}/fish.fish" | ||||||||||||||
| add_source_to_config "$HOME/.bashrc" "${hooks_path}/bash.bash" | ||||||||||||||
| if [ -f "$HOME/.zshrc" ]; then | ||||||||||||||
| add_source_to_config "$HOME/.zshrc" "${hooks_path}/zsh.zsh" | ||||||||||||||
| fi | ||||||||||||||
| if [ -f "$HOME/.config/fish/config.fish" ]; then | ||||||||||||||
| add_source_to_config "$HOME/.config/fish/config.fish" "${hooks_path}/fish.fish" | ||||||||||||||
| fi | ||||||||||||||
|
Comment on lines
+258
to
+260
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency with the fish PATH setup logic (lines 149-160) and the PR description ("Guard fish blocks behind
Suggested change
|
||||||||||||||
| if [ -f "$HOME/.bashrc" ]; then | ||||||||||||||
| add_source_to_config "$HOME/.bashrc" "${hooks_path}/bash.bash" | ||||||||||||||
| fi | ||||||||||||||
|
|
||||||||||||||
| # Reinstall daemon if shelltime is available | ||||||||||||||
| if command_exists shelltime; then | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Removing exit on hooks_path creation failure allows broken source lines to be added to shell configs
When
mkdir -p "$hooks_path"fails at line 198, the old code calledexit 1, preventing any further damage. The new code prints a warning and continues. The script then proceeds to: (1) attemptmkdir -pagain atinstall.bash:238(which also fails), (2) callprocess_fileatinstall.bash:245-252wherecurl -ofails because the directory doesn't exist so no hook files are written, and (3) calladd_source_to_configatinstall.bash:255-263which addssource ~/.shelltime/hooks/zsh.zsh(and similar) lines to the user's shell config files — pointing to files that don't exist. This causes error messages on every new shell session (e.g.,no such file or directoryfrom zsh/bashsource). In shells configured withset -eorsetopt err_exit, this could abort shell initialization entirely.Prompt for agents
Was this helpful? React with 👍 or 👎 to provide feedback.