Skip to content

Instantly share code, notes, and snippets.

@beatlegeuse
Forked from lkptrzk/man.sh
Last active June 24, 2024 07:58
Show Gist options
  • Save beatlegeuse/52a2cae9bf8b1cf5eca63b157986cdc1 to your computer and use it in GitHub Desktop.
Save beatlegeuse/52a2cae9bf8b1cf5eca63b157986cdc1 to your computer and use it in GitHub Desktop.
`man` replacement for git bash on windows
#!/bin/sh
# man.sh - `man` replacement for git bash on windows
if [ $# -eq 0 ] ; then
echo "No command specified to get man page for"
exit 1
fi
url="http://man.he.net/?section=all&topic="
# The extra `+` at the end of the querystring doesn't hurt
for arg in $@ ; do
url=$url$arg"+"
done
curl -s $url | sed -n '/<PRE>/,/<\/PRE>/p' | sed 's/<[^>]*>//g' | perl -MHTML::Entities -pe 'decode_entities($_);' | less
@KSR-Yasuda
Copy link

Could you fix this to return non-zero exit status and skip less, if no man entry is found?
I'd like to check the status, but I don't come up with any simple way without outputting into a file.

@KSR-Yasuda
Copy link

Mine: https://gist.github.com/KSR-Yasuda/84349d909bb576b9dfde0bc4914e67b3
Dump into a temp file, and check output size to return error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment