-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Bug only one command running in if command #19
Comments
Potential solutionThe bug reported suggests that within an To address this, we should ensure that:
What is causing this bug?The bug might be caused by:
CodeTo ensure the script runs correctly, we can add some debugging statements and make sure the script has the correct permissions. Here is the updated #!/bin/bash
# Function to check if the aliases file is sourced in the rc file
check_sourcing() {
if ! grep -qxF ". \"\$HOME/.aliases.sh\"" "$HOME/$1"; then
printf "\n# Sourcing custom aliases\n" >> "${HOME}/$1"
echo ". \"\$HOME/.aliases.sh\"" >> "${HOME}/$1"
fi
if [ -r "${HOME}/$1" ]; then
if ! . "${HOME}/$1"; then
echo "Error: Unable to source ${HOME}/$1"
else
echo "Sourced ${HOME}/$1 successfully."
fi
else
echo "Error: File ${HOME}/$1 does not exist or is not readable."
fi
}
# Function to check for rc files and source the aliases file
check_rc_files() {
if [ -f "$HOME/.bashrc" ]; then
check_sourcing .bashrc
elif [ -f "$HOME/.zshrc" ]; then
check_sourcing .zshrc
elif [ -f "$HOME/.profile" ]; then
check_sourcing .profile
else
echo "Error: rc(bashrc/zshrc/profile) file not found. Please ensure it exists."
fi
}
# Function to download the aliases file using wget
dw_alias_file_wget() {
wget -O "$HOME/.aliases.sh" "https://example.com/aliases.sh"
}
# Function to download the aliases file using curl
dw_alias_file_curl() {
curl -o "$HOME/.aliases.sh" "https://example.com/aliases.sh"
}
# Function to download the aliases file using git
dw_alias_file_git() {
git clone "https://example.com/aliases.git" "$HOME/.aliases"
mv "$HOME/.aliases/aliases.sh" "$HOME/.aliases.sh"
rm -rf "$HOME/.aliases"
}
# Function to download the aliases file
dw_alias_file() {
if command -v wget >/dev/null 2>&1; then
dw_alias_file_wget
elif command -v curl >/dev/null 2>&1; then
dw_alias_file_curl
elif command -v git >/dev/null 2>&1; then
dw_alias_file_git
else
echo "Either install wget, curl, or git"
fi
}
# Main function
main() {
if [ -f "$HOME/.aliases.sh" ]; then
printf "File already exists: %s\n" "$HOME/.aliases.sh"
printf "Do you want to replace it? [y/n]: "
read -r replace_confirmation
replace_confirmation="${replace_confirmation:-y}"
if [ "$replace_confirmation" = "y" ]; then
printf "\nReplacing %s...\n" "$HOME/.aliases.sh"
dw_alias_file
else
printf "\nKeeping existing file: %s\n" "$HOME/.aliases.sh"
fi
else
dw_alias_file
fi
check_rc_files
}
# Ensure the script is executable
chmod +x "$0"
# Run the main function
main How to replicate the bug
If the bug persists, it might be necessary to provide more context or additional files that interact with TaskUser input/requestTicket title: Bug only one command running in if command Ticket Description: The user reported that within an Click here to create a Pull Request with the proposed solution Files used for this task: Changes on main.shBug Analysis Report for
|
PR: #20 |
No description provided.
The text was updated successfully, but these errors were encountered: