Skip to content

Commit

Permalink
Update fp.sh
Browse files Browse the repository at this point in the history
* error handling extended
* awk matches $0 now instead of $NF
- Attempting to match apps that do not put name in last field.
* $app moved into script due to incorrect error handling 
* grammer corrections
  • Loading branch information
DLopezJr authored May 21, 2023
1 parent 2e5a251 commit 0092197
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions fp.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/bin/sh -e
#AUTHOR: David Lopez Jr. /* git(hub|lab).com/dlopezjr */
#PURPOSE: Frontend wrapper for $(flatpak run)
#PURPOSE: Wrapper for $(flatpak run)

#VARIABLE(S)
app=$(flatpak list --app | cut -f2 | awk -F. -v app="$1" '(tolower($NF) ~ tolower(app))')

#FUNCTION(S)
##check if flatpak is installed and accesible to $PATH
command -v flatpak >/dev/null 2>&1 || printf "Flatpak package was not found.\n";
command -v flatpak >/dev/null 2>&1 || { printf "Flatpak package was not found.\n" && exit 1; };

##check if any flatpak packages are installed
test "$(flatpak list --all | head -c1 | wc -c)" -eq "0" && printf "No Flatpak packages are installed.\n" && exit 1;

##check if an app name was entered
test "$#" -eq "0" && printf "Enter an app to fp.\n\$ fp <app>\n\nINSTALLED APPS:\n$(flatpak list --all)\n" && exit 1;

##store reverse dns name for package
app=$(flatpak list --app | cut -f2 | awk -F. -v app="$1" '(tolower($0) ~ tolower(app))')

##check if no arguements were enetered by user
test "$#" -eq "0" && printf "Enter an app to fp.\n\$ fp <app>\n\nINSTALLED APPS\n$app\n" && exit 1;
##check if entered app name is valid
test -z "$app" && printf "Entered app name is invalid.\n" && exit 1;

##remove app name from "$@" array
shift 1;
Expand Down

0 comments on commit 0092197

Please sign in to comment.