git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Error handling when giving empty command line arguments

From
OJOlsson John <john.olsson@saabgroup.com>
Date
May 24, 2022, 13:25 UTC
Message-ID
<dc08a8ee5ed64850872fd6529d1462e1@saabgroup.com>
I have so far only seen this behavior with 'git fetch' command, but it might be more general depending on how command line parsing is implemented.
In a Bash script I had something similar to (but more complicated than what I show below)
  git fetch "${force}"
where $force is either an empty string or '--force'. Due to that you usually want to expand all variables within double quotes when writing Bash scripts I did not realize that I had made a mistake here. Instead I got this strange error message and spent a couple of hours chasing it
  fatal: no path specified; see 'git help pull' for valid url syntax
This problem eventually turned out to be of the trivial kind once I realized why I got it, and also very simple to reproduce. Just do
  $ git fetch ""
  fatal: no path specified; see 'git help pull' for valid url syntax
  $
That is, 'git fetch' does not check if the given string is an empty string before writing the error message. The empty string is completely unrelated to any path/URI and in this case it was not that helpful.
What do you say? Wouldn't it be better with a more specific error message when an option value/argument is an empty string? Or should perhaps empty strings be ignored by the git commands?
/John
Next: Junio C Hamano
Message 1 of 6 in “Error handling when giving empty command line arguments”
  1. Olsson JohnMay 24, 2022
  2. Junio C HamanoMay 24, 2022
  3. Olsson JohnMay 25, 2022
  4. Junio C HamanoMay 25, 2022
  5. Kevin DaudtMay 25, 2022
  6. Olsson JohnMay 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.