forked from msys2/MSYS2-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0006-bash-4.3-add-pwd-W-option.patch
83 lines (73 loc) · 1.88 KB
/
0006-bash-4.3-add-pwd-W-option.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
diff --git a/builtins/cd.def b/builtins/cd.def
index b87c5d9..5e4e78e 100644
--- a/builtins/cd.def
+++ b/builtins/cd.def
@@ -28,6 +28,8 @@ $PRODUCES cd.c
# include <unistd.h>
#endif
+# include <sys/cygwin.h>
+
#include "../bashtypes.h"
#include "posixdir.h"
#include "posixstat.h"
@@ -461,13 +463,14 @@ cd_builtin (list)
$BUILTIN pwd
$FUNCTION pwd_builtin
-$SHORT_DOC pwd [-LP]
+$SHORT_DOC pwd [-LPW]
Print the name of the current working directory.
Options:
-L print the value of $PWD if it names the current working
directory
-P print the physical directory, without any symbolic links
+ -W print the Win32 value of the physical directory
By default, `pwd' behaves as if `-L' were specified.
@@ -485,13 +488,13 @@ int
pwd_builtin (list)
WORD_LIST *list;
{
- char *directory;
+ char *directory, *buffer, *wbuffer;
int opt, pflag;
verbatim_pwd = no_symbolic_links;
pflag = 0;
reset_internal_getopt ();
- while ((opt = internal_getopt (list, "LP")) != -1)
+ while ((opt = internal_getopt (list, "LPW")) != -1)
{
switch (opt)
{
@@ -501,6 +504,9 @@ pwd_builtin (list)
case 'L':
verbatim_pwd = 0;
break;
+ case 'W':
+ verbatim_pwd = 2;
+ break;
CASE_HELPOPT;
default:
builtin_usage ();
@@ -509,6 +515,19 @@ pwd_builtin (list)
}
list = loptend;
+ if (verbatim_pwd == 2) {
+ buffer = xmalloc (PATH_MAX);
+ wbuffer = xmalloc (PATH_MAX);
+ directory = getcwd (buffer, PATH_MAX);
+ cygwin_conv_path (CCP_POSIX_TO_WIN_A|CCP_ABSOLUTE, buffer, wbuffer, PATH_MAX+1);
+ {
+ char *c = wbuffer;
+ while (c = strchr (c, '\\'))
+ *c = '/';
+ }
+ free (buffer);
+ directory = wbuffer;
+ } else {
#define tcwd the_current_working_directory
directory = tcwd ? (verbatim_pwd ? sh_physpath (tcwd, 0) : tcwd)
@@ -525,6 +544,7 @@ pwd_builtin (list)
}
#undef tcwd
+ }
if (directory)
{