-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a Bash script as a wrapper for
port info
The script fetches some online information.
- Loading branch information
1 parent
f8a0ea1
commit 1d040ab
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -o nounset -o pipefail | ||
|
||
function print-field() { | ||
# No idea why MacPorts chose 21 as width | ||
printf '%-21s %s\n' "$1:" "$2" | ||
} | ||
|
||
port info "$@" | ||
return_value=$? | ||
if (( return_value == 0 )) && (( $# == 1 )) && [[ `port file "$1"` == */rsync.macports.org/* ]] | ||
then | ||
print-field 'Port URL' "https://ports.macports.org/port/$1/details/" | ||
if command -v curl >/dev/null | ||
then | ||
package_url="https://packages.macports.org/$1/" | ||
if curl --head --fail --silent "$package_url" >/dev/null | ||
then print-field 'Binary Package' "$package_url" | ||
else print-field 'Binary Package' no | ||
fi | ||
fi | ||
fi | ||
exit $return_value |