|
1 | 1 | #!/bin/bash
|
2 | 2 |
|
3 | 3 | if [[ "$OSTYPE" == "darwin"* ]]; then
|
4 |
| - echo "Detected macOS. Installing jq..." |
5 |
| - if ! command -v brew &> /dev/null; then |
6 |
| - echo "Homebrew is not installed. Installing Homebrew..." |
7 |
| - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
8 |
| - # adding /opt/homebrew/bin to the $PATH variable based on the shell |
9 |
| - if [[ -f "$HOME/.bash_profile" ]]; then |
10 |
| - echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bash_profile" |
11 |
| - source "$HOME/.bash_profile" |
12 |
| - elif [[ -f "$HOME/.zshrc" ]]; then |
13 |
| - echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.zshrc" |
14 |
| - source "$HOME/.zshrc" |
15 |
| - else |
16 |
| - echo "Unsupported shell. Please add /opt/homebrew/bin to your PATH manually." |
17 |
| - |
18 |
| - fi |
19 |
| - brew install jq |
20 |
| - echo "jq has been installed successfully." |
21 |
| - |
| 4 | + echo "Detected macOS. Installing jq..." |
| 5 | + if ! command -v brew &> /dev/null; then |
| 6 | + echo "Homebrew is not installed. Installing Homebrew..." |
| 7 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 8 | + # adding /opt/homebrew/bin to the $PATH variable based on the shell |
| 9 | + if [[ -f "$HOME/.bash_profile" ]]; then |
| 10 | + echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bash_profile" |
| 11 | + source "$HOME/.bash_profile" |
| 12 | + elif [[ -f "$HOME/.bashrc" ]]; then |
| 13 | + echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.bashrc" |
| 14 | + source "$HOME/.bashrc" |
| 15 | + elif [[ -f "$HOME/.zshrc" ]]; then |
| 16 | + echo 'export PATH="/opt/homebrew/bin:$PATH"' >> "$HOME/.zshrc" |
| 17 | + source "$HOME/.zshrc" |
| 18 | + else |
| 19 | + echo "Unsupported shell. Please add /opt/homebrew/bin to your PATH manually." |
| 20 | + exit 1 |
| 21 | + fi |
| 22 | + fi # Closing the brew installation check |
| 23 | + brew install jq |
| 24 | + echo "jq has been installed successfully." |
22 | 25 | elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
23 |
| - echo "Detected Linux. Installing jq..." |
24 |
| - if command -v apt &> /dev/null; then |
25 |
| - sudo apt update |
26 |
| - sudo apt install -y jq |
27 |
| - elif command -v yum &> /dev/null; then |
28 |
| - sudo yum install -y epel-release |
29 |
| - sudo yum install -y jq |
30 |
| - else |
31 |
| - echo "Unsupported package manager. Please install jq manually." |
32 |
| - exit 1 |
33 |
| - fi |
34 |
| - echo "jq has been installed successfully." |
35 |
| - |
| 26 | + echo "Detected Linux. Installing jq..." |
| 27 | + if command -v apt &> /dev/null; then |
| 28 | + sudo apt update |
| 29 | + sudo apt install -y jq |
| 30 | + elif command -v yum &> /dev/null; then |
| 31 | + sudo yum install -y epel-release |
| 32 | + sudo yum install -y jq |
| 33 | + else |
| 34 | + echo "Unsupported package manager. Please install jq manually." |
| 35 | + exit 1 |
| 36 | + fi |
| 37 | + echo "jq has been installed successfully." |
36 | 38 | else
|
37 |
| - echo "Unsupported operating system." |
38 |
| - exit 1 |
39 |
| -fi |
| 39 | + echo "Unsupported operating system." |
| 40 | + exit 1 |
| 41 | +fi # Closing the OS type check |
| 42 | + |
0 commit comments