Fix chrome-history command failing due to variable shadowing#122
Merged
Conversation
These break the chrome_history command. Fix the `chrome-history` command which was failing with "No such file or directory" and "no such table: urls" errors due to local variable shadowing. This function is trying to access the chrome_history and open vars that are in outer scope. Signed-off-by: Keith Lee <keithlee96@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the
chrome-historycommand which always fails with "No such file or directory" and "no such table: urls" errors when called. The variableschrome_historyandopenare not declared inside of the function.This function is trying to access the chrome_history and open vars that are in outer scope.
Problem
The
chrome-history()function declaredchrome_historyandopenas local variables, whichshadowed the global variables set earlier in the script. This caused the function to use empty
local variables instead of the properly initialized global ones containing the Chrome history
file path and system-appropriate open command. This caused this error:
Solution
Remove
chrome_historyandopenfrom the local variable declaration, allowing the functionto access the outer variables.
Checklist
fzf-zsh-plugin.zsh, I have created standalone scripts in bin so they can be used by non-ZSH users too.#!/usr/bin/env interpreterinstead of potentially platform-specific direct paths (#!/bin/shis an ok exception)License Acceptance