diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-10-08 09:13:57 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-10-08 09:13:57 (GMT) |
commit | 5039e7ce17a9ea6c7352b39a0bd70e31433b7843 (patch) | |
tree | 19778475a4ac2e76e5a61dfad2a6d8ea0b120446 | |
parent | 5c9a145403b7329dc839cfca69952604dc70f046 (diff) | |
download | tcl-5039e7ce17a9ea6c7352b39a0bd70e31433b7843.zip tcl-5039e7ce17a9ea6c7352b39a0bd70e31433b7843.tar.gz tcl-5039e7ce17a9ea6c7352b39a0bd70e31433b7843.tar.bz2 |
Fix [014ade1d44]: Misleading error message when using "-path" multiple times with "glob"
-rw-r--r-- | generic/tclFileName.c | 10 | ||||
-rw-r--r-- | tests/fileName.test | 6 |
2 files changed, 14 insertions, 2 deletions
diff --git a/generic/tclFileName.c b/generic/tclFileName.c index 6cdfa7e..b47035c 100644 --- a/generic/tclFileName.c +++ b/generic/tclFileName.c @@ -1281,7 +1281,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-directory\" cannot be used with \"-path\"", -1)); + dir == PATH_DIR + ? "\"-directory\" may only be used once" + : "\"-directory\" cannot be used with \"-path\"", + -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BADOPTIONCOMBINATION", NULL); return TCL_ERROR; @@ -1306,7 +1309,10 @@ Tcl_GlobObjCmd( } if (dir != PATH_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj( - "\"-path\" cannot be used with \"-directory\"", -1)); + dir == PATH_GENERAL + ? "\"-path\" may only be used once" + : "\"-path\" cannot be used with \"-dictionary\"", + -1)); Tcl_SetErrorCode(interp, "TCL", "OPERATION", "GLOB", "BADOPTIONCOMBINATION", NULL); return TCL_ERROR; diff --git a/tests/fileName.test b/tests/fileName.test index 725c1dd..0411ea8 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -1083,6 +1083,12 @@ test filename-11.48 {Tcl_GlobCmd} -returnCodes error -body { test filename-11.49 {Tcl_GlobCmd} -returnCodes error -body { glob -types abcde -path foo -join * * } -result {bad argument to "-types": abcde} +test filename-11.50 {Tcl_GlobCmd} -returnCodes error -body { + glob -path hello -path salut * +} -result {"-path" may only be used once} +test filename-11.51 {Tcl_GlobCmd} -returnCodes error -body { + glob -dir hello -dir salut * +} -result {"-directory" may only be used once} file rename $horribleglobname globTest file delete -force $tildeglobname |