Hacker News new | ask | show | jobs
by Y_Y 430 days ago
From the people who brought you Useless Use of Cat, here's our newest innovation: Useless Use of Bash!

That whole script could just be the last line! Maybe you could add defaults like

    "${port:-8080}"
2 comments

Fair, but don't need to be snooty about it. :-)

    port="${1:-8080}"
    dir="${2:-.}"
Genuinely curious about what the full script would look like in consideration of your feedback.

  python3 -m http.server "${$1:-8080}" "${$2:-.}"
Almost! That will read the variable whose name is is the script argument. Also the directory argument needs a flag on my setup. It should be:

  python3 -mhttp.server "${1:-8080}" -d "${2:-.}"
Yep, you're right.