Skip to content

Commit

Permalink
Create brew-link
Browse files Browse the repository at this point in the history
  • Loading branch information
dnkmmr69420 authored Apr 15, 2024
1 parent c3d1613 commit fa056f9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions bin/brew-link
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Initialize variables with default values
binpath=$HOME/.local/share/clinuxbrew/.linuxbrew/bin

# Parse flags
while getopts ":s" opt; do
case ${opt} in
s )
binpath=$HOME/.local/share/clinuxbrew/.linuxbrew/sbin
;;
\? )
echo "Invalid option: $OPTARG" 1>&2
exit 1
;;
: )
echo "Option -$OPTARG requires an argument" 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))

bin=$1

if [ "$#" -eq 0 ]; then
echo "No arguments provided."
exit 1
fi

if test ! -f $binpath/$bin; then
echo "$bin not found"
exit 1
fi

if test -f $HOME/.local/share/clinuxbrew/.linuxbrew/exports/bin/$bin; then
echo "$bin has already been linked"
exit 1
fi

ln -s $binpath/$bin $HOME/.local/share/clinuxbrew/.linuxbrew/exports/bin/$bin

0 comments on commit fa056f9

Please sign in to comment.