All of lore.kernel.org
 help / color / mirror / Atom feed
* Error handling when giving empty command line arguments
@ 2022-05-24 13:25 Olsson John
  2022-05-24 22:51 ` Junio C Hamano
  2022-05-25  4:41 ` Kevin Daudt
  0 siblings, 2 replies; 6+ messages in thread
From: Olsson John @ 2022-05-24 13:25 UTC (permalink / raw)
  To: git

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-25 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-24 13:25 Error handling when giving empty command line arguments Olsson John
2022-05-24 22:51 ` Junio C Hamano
2022-05-25  7:32   ` [EXTERNAL] " Olsson John
2022-05-25 15:46     ` Junio C Hamano
2022-05-25  4:41 ` Kevin Daudt
2022-05-25  7:03   ` [EXTERNAL] " Olsson John

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.