Make this test case accepts basename() in D script returns "" or "."
In Solaris, basename(1) and basename(3) both return "." while being given an empty string (""), while in BSD (and Linux) basename(1) returns "" and basename(3) returns "." While here, also change #!/usr/bin/ksh to #!/usr/bin/env ksh to find ksh in $PATH Reviewed by: gnn, markj (earlier version), ngie (earlier version) Differential Revision: https://reviews.freebsd.org/D11707
This commit is contained in:
parent
4ca0dfa6b0
commit
5604d0f997
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=321469
@ -55,12 +55,16 @@ BEGIN
|
||||
dir[i++] = "f";
|
||||
dir[i++] = "f/";
|
||||
dir[i++] = "/////";
|
||||
/*
|
||||
* basename(3) and basename(1) return different results for the empty
|
||||
* string on FreeBSD, so we need special handling.
|
||||
dir[i++] = "";
|
||||
*/
|
||||
|
||||
end = i;
|
||||
i = 0;
|
||||
|
||||
printf("#!/usr/bin/ksh\n\n");
|
||||
printf("#!/usr/bin/env ksh\n\n");
|
||||
}
|
||||
|
||||
tick-1ms
|
||||
@ -84,5 +88,19 @@ tick-1ms
|
||||
tick-1ms
|
||||
/i == end/
|
||||
{
|
||||
dir[i] = "";
|
||||
printf("if [ \"`basename \"%s\"`\" != \"%s\" -a \".\" != \"%s\" ]; then\n",
|
||||
dir[i], basename(dir[i]), basename(dir[i]));
|
||||
printf(" echo \"basename(\\\"%s\\\") is \\\"%s\\\"; ",
|
||||
dir[i], basename(dir[i]));
|
||||
printf("expected \\\"`basename \"%s\"`\\\" or \\\".\\\"\"\n", dir[i]);
|
||||
printf("fi\n\n");
|
||||
printf("if [ `dirname \"%s\"` != \"%s\" ]; then\n",
|
||||
dir[i], dirname(dir[i]));
|
||||
printf(" echo \"dirname(\\\"%s\\\") is \\\"%s\\\"; ",
|
||||
dir[i], dirname(dir[i]));
|
||||
printf("expected \\\"`dirname \"%s\"`\"\\\"\n", dir[i]);
|
||||
printf("fi\n\n");
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/ksh
|
||||
#!/usr/bin/env ksh
|
||||
|
||||
if [ `basename "/foo/bar/baz"` != "baz" ]; then
|
||||
echo "basename(\"/foo/bar/baz\") is \"baz\"; expected \"`basename "/foo/bar/baz"`"\"
|
||||
@ -152,8 +152,8 @@ if [ `dirname "/////"` != "/" ]; then
|
||||
echo "dirname(\"/////\") is \"/\"; expected \"`dirname "/////"`"\"
|
||||
fi
|
||||
|
||||
if [ `basename ""` != "." ]; then
|
||||
echo "basename(\"\") is \".\"; expected \"`basename ""`"\"
|
||||
if [ "`basename ""`" != "." -a "." != "." ]; then
|
||||
echo "basename(\"\") is \".\"; expected \"`basename ""`\" or \".\""
|
||||
fi
|
||||
|
||||
if [ `dirname ""` != "." ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user