| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/cd.def |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | - | |||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||
| 13 | - | |||||||||||||||||||||||||||||||
| 14 | - | |||||||||||||||||||||||||||||||
| 15 | - | |||||||||||||||||||||||||||||||
| 16 | - | |||||||||||||||||||||||||||||||
| 17 | - | |||||||||||||||||||||||||||||||
| 18 | - | |||||||||||||||||||||||||||||||
| 19 | - | |||||||||||||||||||||||||||||||
| 20 | extern const char * const bash_getcwd_errstr; | - | ||||||||||||||||||||||||||||||
| 21 | - | |||||||||||||||||||||||||||||||
| 22 | static int bindpwd (int); | - | ||||||||||||||||||||||||||||||
| 23 | static int setpwd (char *); | - | ||||||||||||||||||||||||||||||
| 24 | static char *resetpwd (char *); | - | ||||||||||||||||||||||||||||||
| 25 | static int change_to_directory (char *, int, int); | - | ||||||||||||||||||||||||||||||
| 26 | - | |||||||||||||||||||||||||||||||
| 27 | static int cdxattr (char *, char **); | - | ||||||||||||||||||||||||||||||
| 28 | static void resetxattr (void); | - | ||||||||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||||||||
| 30 | - | |||||||||||||||||||||||||||||||
| 31 | int cdspelling = 0; | - | ||||||||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||||||||
| 33 | int cdable_vars; | - | ||||||||||||||||||||||||||||||
| 34 | - | |||||||||||||||||||||||||||||||
| 35 | static int eflag; | - | ||||||||||||||||||||||||||||||
| 36 | static int xattrflag; | - | ||||||||||||||||||||||||||||||
| 37 | static int xattrfd = -1; | - | ||||||||||||||||||||||||||||||
| 38 | - | |||||||||||||||||||||||||||||||
| 39 | - | |||||||||||||||||||||||||||||||
| 40 | static int | - | ||||||||||||||||||||||||||||||
| 41 | setpwd (dirname) | - | ||||||||||||||||||||||||||||||
| 42 | char *dirname; | - | ||||||||||||||||||||||||||||||
| 43 | { | - | ||||||||||||||||||||||||||||||
| 44 | int old_anm; | - | ||||||||||||||||||||||||||||||
| 45 | SHELL_VAR *tvar; | - | ||||||||||||||||||||||||||||||
| 46 | - | |||||||||||||||||||||||||||||||
| 47 | old_anm = array_needs_making; | - | ||||||||||||||||||||||||||||||
| 48 | tvar = bind_variable ("PWD", dirname ? dirname : "", 0); | - | ||||||||||||||||||||||||||||||
| 49 | if (tvar
| 0-66 | ||||||||||||||||||||||||||||||
| 50 | return never executed: 1;return 1;never executed: return 1; | 0 | ||||||||||||||||||||||||||||||
| 51 | if (tvar
| 0-66 | ||||||||||||||||||||||||||||||
| 52 | { | - | ||||||||||||||||||||||||||||||
| 53 | update_export_env_inplace ("PWD=", 4, dirname ? dirname : ""); | - | ||||||||||||||||||||||||||||||
| 54 | array_needs_making = 0; | - | ||||||||||||||||||||||||||||||
| 55 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 56 | return executed 66 times by 1 test: 0;return 0;Executed by:
executed 66 times by 1 test: return 0;Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 57 | } | - | ||||||||||||||||||||||||||||||
| 58 | - | |||||||||||||||||||||||||||||||
| 59 | static int | - | ||||||||||||||||||||||||||||||
| 60 | bindpwd (no_symlinks) | - | ||||||||||||||||||||||||||||||
| 61 | int no_symlinks; | - | ||||||||||||||||||||||||||||||
| 62 | { | - | ||||||||||||||||||||||||||||||
| 63 | char *dirname, *pwdvar; | - | ||||||||||||||||||||||||||||||
| 64 | int old_anm, r; | - | ||||||||||||||||||||||||||||||
| 65 | SHELL_VAR *tvar; | - | ||||||||||||||||||||||||||||||
| 66 | - | |||||||||||||||||||||||||||||||
| 67 | r = sh_chkwrite (0); | - | ||||||||||||||||||||||||||||||
| 68 | - | |||||||||||||||||||||||||||||||
| 69 | - | |||||||||||||||||||||||||||||||
| 70 | dirname = the_current_working_directory
| 0-66 | ||||||||||||||||||||||||||||||
| 71 | : get_working_directory ("cd"); | - | ||||||||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||||||||
| 74 | old_anm = array_needs_making; | - | ||||||||||||||||||||||||||||||
| 75 | pwdvar = get_string_value ("PWD"); | - | ||||||||||||||||||||||||||||||
| 76 | - | |||||||||||||||||||||||||||||||
| 77 | tvar = bind_variable ("OLDPWD", pwdvar, 0); | - | ||||||||||||||||||||||||||||||
| 78 | if (tvar
| 0-66 | ||||||||||||||||||||||||||||||
| 79 | r = 1; never executed: r = 1; | 0 | ||||||||||||||||||||||||||||||
| 80 | - | |||||||||||||||||||||||||||||||
| 81 | if (old_anm == 0
| 0-44 | ||||||||||||||||||||||||||||||
| 82 | { | - | ||||||||||||||||||||||||||||||
| 83 | update_export_env_inplace ("OLDPWD=", 7, pwdvar); | - | ||||||||||||||||||||||||||||||
| 84 | array_needs_making = 0; | - | ||||||||||||||||||||||||||||||
| 85 | } executed 44 times by 1 test: end of blockExecuted by:
| 44 | ||||||||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||||||||
| 87 | if (setpwd (dirname) == 1
| 0-66 | ||||||||||||||||||||||||||||||
| 88 | r = 1; never executed: r = 1; | 0 | ||||||||||||||||||||||||||||||
| 89 | if (dirname == 0
| 0-66 | ||||||||||||||||||||||||||||||
| 90 | r = 1; never executed: r = 1; | 0 | ||||||||||||||||||||||||||||||
| 91 | - | |||||||||||||||||||||||||||||||
| 92 | if (dirname
| 0-66 | ||||||||||||||||||||||||||||||
| 93 | sh_xfree((dirname), "./cd.def", 170); executed 1 time by 1 test: sh_xfree((dirname), "./cd.def", 170);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 94 | - | |||||||||||||||||||||||||||||||
| 95 | return executed 66 times by 1 test: (r);return (r);Executed by:
executed 66 times by 1 test: return (r);Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 96 | } | - | ||||||||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||||||||
| 100 | static char * | - | ||||||||||||||||||||||||||||||
| 101 | resetpwd (caller) | - | ||||||||||||||||||||||||||||||
| 102 | char *caller; | - | ||||||||||||||||||||||||||||||
| 103 | { | - | ||||||||||||||||||||||||||||||
| 104 | char *tdir; | - | ||||||||||||||||||||||||||||||
| 105 | - | |||||||||||||||||||||||||||||||
| 106 | do { if (the_current_working_directory
never executed: } while (0);sh_xfree((the_current_working_directory), "./cd.def", 183); | 0 | ||||||||||||||||||||||||||||||
| 107 | the_current_working_directory = (char *) | - | ||||||||||||||||||||||||||||||
| 108 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 109 | ; | - | ||||||||||||||||||||||||||||||
| 110 | tdir = get_working_directory (caller); | - | ||||||||||||||||||||||||||||||
| 111 | return never executed: (tdir);return (tdir);never executed: return (tdir); | 0 | ||||||||||||||||||||||||||||||
| 112 | } | - | ||||||||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||||||||
| 114 | static int | - | ||||||||||||||||||||||||||||||
| 115 | cdxattr (dir, ndirp) | - | ||||||||||||||||||||||||||||||
| 116 | char *dir; | - | ||||||||||||||||||||||||||||||
| 117 | char **ndirp; | - | ||||||||||||||||||||||||||||||
| 118 | { | - | ||||||||||||||||||||||||||||||
| 119 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||||||||
| 120 | - | |||||||||||||||||||||||||||||||
| 121 | } | - | ||||||||||||||||||||||||||||||
| 122 | - | |||||||||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||||||||
| 124 | static void | - | ||||||||||||||||||||||||||||||
| 125 | resetxattr () | - | ||||||||||||||||||||||||||||||
| 126 | { | - | ||||||||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||||||||
| 128 | - | |||||||||||||||||||||||||||||||
| 129 | - | |||||||||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||||||||
| 131 | - | |||||||||||||||||||||||||||||||
| 132 | - | |||||||||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||||||||
| 134 | xattrfd = -1; | - | ||||||||||||||||||||||||||||||
| 135 | - | |||||||||||||||||||||||||||||||
| 136 | } executed 66 times by 1 test: end of blockExecuted by:
| 66 | ||||||||||||||||||||||||||||||
| 137 | int | - | ||||||||||||||||||||||||||||||
| 138 | cd_builtin (list) | - | ||||||||||||||||||||||||||||||
| 139 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
| 140 | { | - | ||||||||||||||||||||||||||||||
| 141 | char *dirname, *cdpath, *path, *temp; | - | ||||||||||||||||||||||||||||||
| 142 | int path_index, no_symlinks, opt, lflag, e; | - | ||||||||||||||||||||||||||||||
| 143 | - | |||||||||||||||||||||||||||||||
| 144 | - | |||||||||||||||||||||||||||||||
| 145 | if (restricted
| 1-73 | ||||||||||||||||||||||||||||||
| 146 | { | - | ||||||||||||||||||||||||||||||
| 147 | sh_restricted ((char *) | - | ||||||||||||||||||||||||||||||
| 148 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 149 | ); | - | ||||||||||||||||||||||||||||||
| 150 | return executed 1 time by 1 test: (1);return (1);Executed by:
executed 1 time by 1 test: return (1);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 151 | } | - | ||||||||||||||||||||||||||||||
| 152 | - | |||||||||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||||||||
| 154 | eflag = 0; | - | ||||||||||||||||||||||||||||||
| 155 | no_symlinks = no_symbolic_links; | - | ||||||||||||||||||||||||||||||
| 156 | xattrflag = 0; | - | ||||||||||||||||||||||||||||||
| 157 | reset_internal_getopt (); | - | ||||||||||||||||||||||||||||||
| 158 | - | |||||||||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||||||||
| 160 | - | |||||||||||||||||||||||||||||||
| 161 | while ((
| 1-73 | ||||||||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||||||||
| 163 | { | - | ||||||||||||||||||||||||||||||
| 164 | switch (opt) | - | ||||||||||||||||||||||||||||||
| 165 | { | - | ||||||||||||||||||||||||||||||
| 166 | case executed 1 time by 1 test: 'P':case 'P':Executed by:
executed 1 time by 1 test: case 'P':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 167 | no_symlinks = 1; | - | ||||||||||||||||||||||||||||||
| 168 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 169 | case never executed: 'L':case 'L':never executed: case 'L': | 0 | ||||||||||||||||||||||||||||||
| 170 | no_symlinks = 0; | - | ||||||||||||||||||||||||||||||
| 171 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 172 | case never executed: 'e':case 'e':never executed: case 'e': | 0 | ||||||||||||||||||||||||||||||
| 173 | eflag = 1; | - | ||||||||||||||||||||||||||||||
| 174 | break; never executed: break; | 0 | ||||||||||||||||||||||||||||||
| 175 | - | |||||||||||||||||||||||||||||||
| 176 | - | |||||||||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||||||||
| 178 | - | |||||||||||||||||||||||||||||||
| 179 | - | |||||||||||||||||||||||||||||||
| 180 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||||||||
| 181 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 182 | builtin_usage (); | - | ||||||||||||||||||||||||||||||
| 183 | return never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||||||||
| 184 | } | - | ||||||||||||||||||||||||||||||
| 185 | } | - | ||||||||||||||||||||||||||||||
| 186 | list = loptend; | - | ||||||||||||||||||||||||||||||
| 187 | - | |||||||||||||||||||||||||||||||
| 188 | lflag = (cdable_vars
| 0-73 | ||||||||||||||||||||||||||||||
| 189 | ((interactive && cdspelling) ? 0x002 : 0); | - | ||||||||||||||||||||||||||||||
| 190 | if (eflag
| 0-73 | ||||||||||||||||||||||||||||||
| 191 | eflag = 0; never executed: eflag = 0; | 0 | ||||||||||||||||||||||||||||||
| 192 | - | |||||||||||||||||||||||||||||||
| 193 | if (list == 0
| 2-71 | ||||||||||||||||||||||||||||||
| 194 | { | - | ||||||||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||||||||
| 196 | dirname = get_string_value ("HOME"); | - | ||||||||||||||||||||||||||||||
| 197 | - | |||||||||||||||||||||||||||||||
| 198 | if (dirname == 0
| 1 | ||||||||||||||||||||||||||||||
| 199 | { | - | ||||||||||||||||||||||||||||||
| 200 | builtin_error ( | - | ||||||||||||||||||||||||||||||
| 201 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
| 202 | "HOME not set" | - | ||||||||||||||||||||||||||||||
| 203 | , 5) | - | ||||||||||||||||||||||||||||||
| 204 | ); | - | ||||||||||||||||||||||||||||||
| 205 | return executed 1 time by 1 test: (1);return (1);Executed by:
executed 1 time by 1 test: return (1);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 206 | } | - | ||||||||||||||||||||||||||||||
| 207 | lflag = 0; | - | ||||||||||||||||||||||||||||||
| 208 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||||||||
| 210 | else if (list->next
| 0-71 | ||||||||||||||||||||||||||||||
| 211 | { | - | ||||||||||||||||||||||||||||||
| 212 | builtin_error ( | - | ||||||||||||||||||||||||||||||
| 213 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
| 214 | "too many arguments" | - | ||||||||||||||||||||||||||||||
| 215 | , 5) | - | ||||||||||||||||||||||||||||||
| 216 | ); | - | ||||||||||||||||||||||||||||||
| 217 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
| 218 | } | - | ||||||||||||||||||||||||||||||
| 219 | else if (list->word->word[0] == '-'
| 0-69 | ||||||||||||||||||||||||||||||
| 220 | { | - | ||||||||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||||||||
| 222 | dirname = get_string_value ("OLDPWD"); | - | ||||||||||||||||||||||||||||||
| 223 | - | |||||||||||||||||||||||||||||||
| 224 | if (dirname == 0
| 1 | ||||||||||||||||||||||||||||||
| 225 | { | - | ||||||||||||||||||||||||||||||
| 226 | builtin_error ( | - | ||||||||||||||||||||||||||||||
| 227 | dcgettext (((void *)0), | - | ||||||||||||||||||||||||||||||
| 228 | "OLDPWD not set" | - | ||||||||||||||||||||||||||||||
| 229 | , 5) | - | ||||||||||||||||||||||||||||||
| 230 | ); | - | ||||||||||||||||||||||||||||||
| 231 | return executed 1 time by 1 test: (1);return (1);Executed by:
executed 1 time by 1 test: return (1);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 232 | } | - | ||||||||||||||||||||||||||||||
| 233 | - | |||||||||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||||||||
| 236 | lflag = 0x004; | - | ||||||||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||||||||
| 238 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||||||||||||||
| 239 | else if (absolute_pathname (list->word->word)
| 2-67 | ||||||||||||||||||||||||||||||
| 240 | dirname = list->word->word; executed 67 times by 1 test: dirname = list->word->word;Executed by:
| 67 | ||||||||||||||||||||||||||||||
| 241 | else if (privileged_mode == 0
| 0-2 | ||||||||||||||||||||||||||||||
| 242 | { | - | ||||||||||||||||||||||||||||||
| 243 | dirname = list->word->word; | - | ||||||||||||||||||||||||||||||
| 244 | - | |||||||||||||||||||||||||||||||
| 245 | - | |||||||||||||||||||||||||||||||
| 246 | path_index = 0; | - | ||||||||||||||||||||||||||||||
| 247 | while (path = extract_colon_unit (cdpath, &path_index)
| 0-2 | ||||||||||||||||||||||||||||||
| 248 | { | - | ||||||||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||||||||
| 250 | opt = path[0] != '\0'; | - | ||||||||||||||||||||||||||||||
| 251 | temp = sh_makepath (path, dirname, 0x01); | - | ||||||||||||||||||||||||||||||
| 252 | sh_xfree((path), "./cd.def", 367); | - | ||||||||||||||||||||||||||||||
| 253 | - | |||||||||||||||||||||||||||||||
| 254 | if (change_to_directory (temp, no_symlinks, xattrflag)
| 1 | ||||||||||||||||||||||||||||||
| 255 | { | - | ||||||||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||||||||
| 257 | - | |||||||||||||||||||||||||||||||
| 258 | - | |||||||||||||||||||||||||||||||
| 259 | - | |||||||||||||||||||||||||||||||
| 260 | if (opt
| 0-1 | ||||||||||||||||||||||||||||||
| 261 | printf ("%s\n", path); executed 1 time by 1 test: printf ("%s\n", path);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 262 | - | |||||||||||||||||||||||||||||||
| 263 | sh_xfree((temp), "./cd.def", 378); | - | ||||||||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||||||||
| 266 | - | |||||||||||||||||||||||||||||||
| 267 | - | |||||||||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||||||||
| 269 | return executed 1 time by 1 test: (bindpwd (no_symlinks));return (bindpwd (no_symlinks));Executed by:
executed 1 time by 1 test: return (bindpwd (no_symlinks));Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 270 | - | |||||||||||||||||||||||||||||||
| 271 | } | - | ||||||||||||||||||||||||||||||
| 272 | else | - | ||||||||||||||||||||||||||||||
| 273 | sh_xfree((temp), "./cd.def", 388); executed 1 time by 1 test: sh_xfree((temp), "./cd.def", 388);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 274 | } | - | ||||||||||||||||||||||||||||||
| 275 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 276 | else | - | ||||||||||||||||||||||||||||||
| 277 | dirname = list->word->word; executed 1 time by 1 test: dirname = list->word->word;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 278 | - | |||||||||||||||||||||||||||||||
| 279 | - | |||||||||||||||||||||||||||||||
| 280 | - | |||||||||||||||||||||||||||||||
| 281 | if (change_to_directory (dirname, no_symlinks, xattrflag)
| 5-65 | ||||||||||||||||||||||||||||||
| 282 | { | - | ||||||||||||||||||||||||||||||
| 283 | if (lflag & 0x004
| 0-65 | ||||||||||||||||||||||||||||||
| 284 | printf ("%s\n", dirname); never executed: printf ("%s\n", dirname); | 0 | ||||||||||||||||||||||||||||||
| 285 | return executed 65 times by 1 test: (bindpwd (no_symlinks));return (bindpwd (no_symlinks));Executed by:
executed 65 times by 1 test: return (bindpwd (no_symlinks));Executed by:
| 65 | ||||||||||||||||||||||||||||||
| 286 | } | - | ||||||||||||||||||||||||||||||
| 287 | - | |||||||||||||||||||||||||||||||
| 288 | - | |||||||||||||||||||||||||||||||
| 289 | - | |||||||||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||||||||
| 291 | if (lflag & 0x001
| 0-5 | ||||||||||||||||||||||||||||||
| 292 | { | - | ||||||||||||||||||||||||||||||
| 293 | temp = get_string_value (dirname); | - | ||||||||||||||||||||||||||||||
| 294 | if (temp
| 0 | ||||||||||||||||||||||||||||||
| 295 | { | - | ||||||||||||||||||||||||||||||
| 296 | printf ("%s\n", temp); | - | ||||||||||||||||||||||||||||||
| 297 | return never executed: (bindpwd (no_symlinks));return (bindpwd (no_symlinks));never executed: return (bindpwd (no_symlinks)); | 0 | ||||||||||||||||||||||||||||||
| 298 | } | - | ||||||||||||||||||||||||||||||
| 299 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||||||||
| 301 | - | |||||||||||||||||||||||||||||||
| 302 | - | |||||||||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||||||||
| 304 | if (lflag & 0x002
| 0-5 | ||||||||||||||||||||||||||||||
| 305 | { | - | ||||||||||||||||||||||||||||||
| 306 | temp = dirspell (dirname); | - | ||||||||||||||||||||||||||||||
| 307 | if (temp
| 0 | ||||||||||||||||||||||||||||||
| 308 | { | - | ||||||||||||||||||||||||||||||
| 309 | printf ("%s\n", temp); | - | ||||||||||||||||||||||||||||||
| 310 | sh_xfree((temp), "./cd.def", 439); | - | ||||||||||||||||||||||||||||||
| 311 | return never executed: (bindpwd (no_symlinks));return (bindpwd (no_symlinks));never executed: return (bindpwd (no_symlinks)); | 0 | ||||||||||||||||||||||||||||||
| 312 | } | - | ||||||||||||||||||||||||||||||
| 313 | else | - | ||||||||||||||||||||||||||||||
| 314 | do { if (temp
never executed: }sh_xfree((temp), "./cd.def", 443);never executed: while (0);end of block | 0 | ||||||||||||||||||||||||||||||
| 315 | } | - | ||||||||||||||||||||||||||||||
| 316 | - | |||||||||||||||||||||||||||||||
| 317 | e = | - | ||||||||||||||||||||||||||||||
| 318 | (*__errno_location ()) | - | ||||||||||||||||||||||||||||||
| 319 | ; | - | ||||||||||||||||||||||||||||||
| 320 | temp = printable_filename (dirname, 0); | - | ||||||||||||||||||||||||||||||
| 321 | builtin_error ("%s: %s", temp, strerror (e)); | - | ||||||||||||||||||||||||||||||
| 322 | if (temp != dirname
| 1-4 | ||||||||||||||||||||||||||||||
| 323 | sh_xfree((temp), "./cd.def", 450); executed 1 time by 1 test: sh_xfree((temp), "./cd.def", 450);Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 324 | return executed 5 times by 1 test: (1);return (1);Executed by:
executed 5 times by 1 test: return (1);Executed by:
| 5 | ||||||||||||||||||||||||||||||
| 325 | } | - | ||||||||||||||||||||||||||||||
| 326 | - | |||||||||||||||||||||||||||||||
| 327 | - | |||||||||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||||||||
| 329 | static int verbatim_pwd; | - | ||||||||||||||||||||||||||||||
| 330 | - | |||||||||||||||||||||||||||||||
| 331 | - | |||||||||||||||||||||||||||||||
| 332 | int | - | ||||||||||||||||||||||||||||||
| 333 | pwd_builtin (list) | - | ||||||||||||||||||||||||||||||
| 334 | WORD_LIST *list; | - | ||||||||||||||||||||||||||||||
| 335 | { | - | ||||||||||||||||||||||||||||||
| 336 | char *directory; | - | ||||||||||||||||||||||||||||||
| 337 | int opt, pflag; | - | ||||||||||||||||||||||||||||||
| 338 | - | |||||||||||||||||||||||||||||||
| 339 | verbatim_pwd = no_symbolic_links; | - | ||||||||||||||||||||||||||||||
| 340 | pflag = 0; | - | ||||||||||||||||||||||||||||||
| 341 | reset_internal_getopt (); | - | ||||||||||||||||||||||||||||||
| 342 | while ((
| 3-9 | ||||||||||||||||||||||||||||||
| 343 | { | - | ||||||||||||||||||||||||||||||
| 344 | switch (opt) | - | ||||||||||||||||||||||||||||||
| 345 | { | - | ||||||||||||||||||||||||||||||
| 346 | case executed 2 times by 1 test: 'P':case 'P':Executed by:
executed 2 times by 1 test: case 'P':Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 347 | verbatim_pwd = pflag = 1; | - | ||||||||||||||||||||||||||||||
| 348 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 349 | case executed 1 time by 1 test: 'L':case 'L':Executed by:
executed 1 time by 1 test: case 'L':Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 350 | verbatim_pwd = 0; | - | ||||||||||||||||||||||||||||||
| 351 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 352 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||||||||
| 353 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||||||||||||||
| 354 | builtin_usage (); | - | ||||||||||||||||||||||||||||||
| 355 | return never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||||||||||||||||||||
| 356 | } | - | ||||||||||||||||||||||||||||||
| 357 | } | - | ||||||||||||||||||||||||||||||
| 358 | list = loptend; | - | ||||||||||||||||||||||||||||||
| 359 | - | |||||||||||||||||||||||||||||||
| 360 | - | |||||||||||||||||||||||||||||||
| 361 | - | |||||||||||||||||||||||||||||||
| 362 | directory = the_current_working_directory
| 0-9 | ||||||||||||||||||||||||||||||
| 363 | : get_working_directory ("pwd"); | - | ||||||||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||||||||
| 365 | - | |||||||||||||||||||||||||||||||
| 366 | - | |||||||||||||||||||||||||||||||
| 367 | if ((the_current_working_directory
| 0-9 | ||||||||||||||||||||||||||||||
| 368 | (posixly_correct
| 0-9 | ||||||||||||||||||||||||||||||
| 369 | { | - | ||||||||||||||||||||||||||||||
| 370 | if (directory
| 0 | ||||||||||||||||||||||||||||||
| 371 | sh_xfree((directory), "./cd.def", 515); never executed: sh_xfree((directory), "./cd.def", 515); | 0 | ||||||||||||||||||||||||||||||
| 372 | directory = resetpwd ("pwd"); | - | ||||||||||||||||||||||||||||||
| 373 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 374 | - | |||||||||||||||||||||||||||||||
| 375 | - | |||||||||||||||||||||||||||||||
| 376 | - | |||||||||||||||||||||||||||||||
| 377 | if (directory
| 0-9 | ||||||||||||||||||||||||||||||
| 378 | { | - | ||||||||||||||||||||||||||||||
| 379 | opt = 0; | - | ||||||||||||||||||||||||||||||
| 380 | printf ("%s\n", directory); | - | ||||||||||||||||||||||||||||||
| 381 | - | |||||||||||||||||||||||||||||||
| 382 | if (posixly_correct
| 0-9 | ||||||||||||||||||||||||||||||
| 383 | opt = setpwd (directory); never executed: opt = setpwd (directory); | 0 | ||||||||||||||||||||||||||||||
| 384 | if (directory != the_current_working_directory
| 2-7 | ||||||||||||||||||||||||||||||
| 385 | sh_xfree((directory), "./cd.def", 529); executed 2 times by 1 test: sh_xfree((directory), "./cd.def", 529);Executed by:
| 2 | ||||||||||||||||||||||||||||||
| 386 | return executed 9 times by 1 test: (sh_chkwrite (opt));return (sh_chkwrite (opt));Executed by:
executed 9 times by 1 test: return (sh_chkwrite (opt));Executed by:
| 9 | ||||||||||||||||||||||||||||||
| 387 | } | - | ||||||||||||||||||||||||||||||
| 388 | else | - | ||||||||||||||||||||||||||||||
| 389 | return never executed: (1);return (1);never executed: return (1); | 0 | ||||||||||||||||||||||||||||||
| 390 | } | - | ||||||||||||||||||||||||||||||
| 391 | - | |||||||||||||||||||||||||||||||
| 392 | - | |||||||||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||||||||
| 394 | - | |||||||||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||||||||
| 396 | - | |||||||||||||||||||||||||||||||
| 397 | - | |||||||||||||||||||||||||||||||
| 398 | static int | - | ||||||||||||||||||||||||||||||
| 399 | change_to_directory (newdir, nolinks, xattr) | - | ||||||||||||||||||||||||||||||
| 400 | char *newdir; | - | ||||||||||||||||||||||||||||||
| 401 | int nolinks, xattr; | - | ||||||||||||||||||||||||||||||
| 402 | { | - | ||||||||||||||||||||||||||||||
| 403 | char *t, *tdir, *ndir; | - | ||||||||||||||||||||||||||||||
| 404 | int err, canon_failed, r, ndlen; | - | ||||||||||||||||||||||||||||||
| 405 | - | |||||||||||||||||||||||||||||||
| 406 | tdir = (char *) | - | ||||||||||||||||||||||||||||||
| 407 | ((void *)0) | - | ||||||||||||||||||||||||||||||
| 408 | ; | - | ||||||||||||||||||||||||||||||
| 409 | - | |||||||||||||||||||||||||||||||
| 410 | if (the_current_working_directory == 0
| 0-72 | ||||||||||||||||||||||||||||||
| 411 | { | - | ||||||||||||||||||||||||||||||
| 412 | t = get_working_directory ("chdir"); | - | ||||||||||||||||||||||||||||||
| 413 | do { if (t
never executed: } while (0);sh_xfree((t), "./cd.def", 555); | 0 | ||||||||||||||||||||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||||||||
| 416 | t = make_absolute (newdir, the_current_working_directory); | - | ||||||||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||||||||
| 418 | - | |||||||||||||||||||||||||||||||
| 419 | - | |||||||||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||||||||
| 421 | tdir = nolinks
| 1-71 | ||||||||||||||||||||||||||||||
| 422 | : sh_canonpath (t, 0x0001|0x0002); | - | ||||||||||||||||||||||||||||||
| 423 | - | |||||||||||||||||||||||||||||||
| 424 | ndlen = strlen (newdir); | - | ||||||||||||||||||||||||||||||
| 425 | - | |||||||||||||||||||||||||||||||
| 426 | - | |||||||||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||||||||
| 428 | canon_failed = 0; | - | ||||||||||||||||||||||||||||||
| 429 | if (tdir
| 0-66 | ||||||||||||||||||||||||||||||
| 430 | sh_xfree((t), "./cd.def", 572); executed 66 times by 1 test: sh_xfree((t), "./cd.def", 572);Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 431 | else | - | ||||||||||||||||||||||||||||||
| 432 | { | - | ||||||||||||||||||||||||||||||
| 433 | do { if (tdir
never executed: } while (0);sh_xfree((tdir), "./cd.def", 575); | 0-6 | ||||||||||||||||||||||||||||||
| 434 | tdir = t; | - | ||||||||||||||||||||||||||||||
| 435 | canon_failed = 1; | - | ||||||||||||||||||||||||||||||
| 436 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||||||||
| 441 | if (posixly_correct
| 0-72 | ||||||||||||||||||||||||||||||
| 442 | (*
| 0 | ||||||||||||||||||||||||||||||
| 443 | !=
| 0 | ||||||||||||||||||||||||||||||
| 444 | 36
| 0 | ||||||||||||||||||||||||||||||
| 445 | || ndlen >
| 0 | ||||||||||||||||||||||||||||||
| 446 | 4096
| 0 | ||||||||||||||||||||||||||||||
| 447 | )) | - | ||||||||||||||||||||||||||||||
| 448 | { | - | ||||||||||||||||||||||||||||||
| 449 | - | |||||||||||||||||||||||||||||||
| 450 | if ( | - | ||||||||||||||||||||||||||||||
| 451 | (*
| 0 | ||||||||||||||||||||||||||||||
| 452 | !=
| 0 | ||||||||||||||||||||||||||||||
| 453 | 2
| 0 | ||||||||||||||||||||||||||||||
| 454 | && | - | ||||||||||||||||||||||||||||||
| 455 | (*
| 0 | ||||||||||||||||||||||||||||||
| 456 | !=
| 0 | ||||||||||||||||||||||||||||||
| 457 | 36
| 0 | ||||||||||||||||||||||||||||||
| 458 | ) | - | ||||||||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||||||||
| 460 | - | |||||||||||||||||||||||||||||||
| 461 | - | |||||||||||||||||||||||||||||||
| 462 | - | |||||||||||||||||||||||||||||||
| 463 | (* never executed: (*__errno_location ()) = 20 ;never executed: __errno_location ()) (*__errno_location ()) = 20 ;never executed: (*__errno_location ()) = 20 ; | 0 | ||||||||||||||||||||||||||||||
| 464 | = never executed: (*__errno_location ()) = 20 ; | 0 | ||||||||||||||||||||||||||||||
| 465 | 20 never executed: (*__errno_location ()) = 20 ; | 0 | ||||||||||||||||||||||||||||||
| 466 | ; never executed: (*__errno_location ()) = 20 ; | 0 | ||||||||||||||||||||||||||||||
| 467 | sh_xfree((tdir), "./cd.def", 591); | - | ||||||||||||||||||||||||||||||
| 468 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
| 469 | } | - | ||||||||||||||||||||||||||||||
| 470 | { | - | ||||||||||||||||||||||||||||||
| 471 | r = chdir (nolinks ? newdir : tdir); | - | ||||||||||||||||||||||||||||||
| 472 | if (r >= 0
| 6-66 | ||||||||||||||||||||||||||||||
| 473 | resetxattr (); executed 66 times by 1 test: resetxattr ();Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 474 | } | - | ||||||||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||||||||
| 477 | if (r == 0
| 6-66 | ||||||||||||||||||||||||||||||
| 478 | { | - | ||||||||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||||||||
| 481 | if (canon_failed
| 0-66 | ||||||||||||||||||||||||||||||
| 482 | { | - | ||||||||||||||||||||||||||||||
| 483 | t = resetpwd ("cd"); | - | ||||||||||||||||||||||||||||||
| 484 | if (t == 0
| 0 | ||||||||||||||||||||||||||||||
| 485 | set_working_directory (tdir); never executed: set_working_directory (tdir); | 0 | ||||||||||||||||||||||||||||||
| 486 | else | - | ||||||||||||||||||||||||||||||
| 487 | sh_xfree((t), "./cd.def", 632); never executed: sh_xfree((t), "./cd.def", 632); | 0 | ||||||||||||||||||||||||||||||
| 488 | } | - | ||||||||||||||||||||||||||||||
| 489 | else | - | ||||||||||||||||||||||||||||||
| 490 | set_working_directory (tdir); executed 66 times by 1 test: set_working_directory (tdir);Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||||||||
| 492 | sh_xfree((tdir), "./cd.def", 637); | - | ||||||||||||||||||||||||||||||
| 493 | return executed 66 times by 1 test: (1);return (1);Executed by:
executed 66 times by 1 test: return (1);Executed by:
| 66 | ||||||||||||||||||||||||||||||
| 494 | } | - | ||||||||||||||||||||||||||||||
| 495 | - | |||||||||||||||||||||||||||||||
| 496 | - | |||||||||||||||||||||||||||||||
| 497 | - | |||||||||||||||||||||||||||||||
| 498 | if (nolinks
| 0-6 | ||||||||||||||||||||||||||||||
| 499 | { | - | ||||||||||||||||||||||||||||||
| 500 | sh_xfree((tdir), "./cd.def", 645); | - | ||||||||||||||||||||||||||||||
| 501 | return never executed: (0);return (0);never executed: return (0); | 0 | ||||||||||||||||||||||||||||||
| 502 | } | - | ||||||||||||||||||||||||||||||
| 503 | - | |||||||||||||||||||||||||||||||
| 504 | err = | - | ||||||||||||||||||||||||||||||
| 505 | (*__errno_location ()) | - | ||||||||||||||||||||||||||||||
| 506 | ; | - | ||||||||||||||||||||||||||||||
| 507 | - | |||||||||||||||||||||||||||||||
| 508 | - | |||||||||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||||||||
| 510 | - | |||||||||||||||||||||||||||||||
| 511 | if (chdir (newdir) == 0
| 0-6 | ||||||||||||||||||||||||||||||
| 512 | { | - | ||||||||||||||||||||||||||||||
| 513 | t = resetpwd ("cd"); | - | ||||||||||||||||||||||||||||||
| 514 | if (t == 0
| 0 | ||||||||||||||||||||||||||||||
| 515 | set_working_directory (tdir); never executed: set_working_directory (tdir); | 0 | ||||||||||||||||||||||||||||||
| 516 | else | - | ||||||||||||||||||||||||||||||
| 517 | sh_xfree((t), "./cd.def", 660); never executed: sh_xfree((t), "./cd.def", 660); | 0 | ||||||||||||||||||||||||||||||
| 518 | - | |||||||||||||||||||||||||||||||
| 519 | r = 1; | - | ||||||||||||||||||||||||||||||
| 520 | } never executed: end of block | 0 | ||||||||||||||||||||||||||||||
| 521 | else | - | ||||||||||||||||||||||||||||||
| 522 | { | - | ||||||||||||||||||||||||||||||
| 523 | - | |||||||||||||||||||||||||||||||
| 524 | (*__errno_location ()) | - | ||||||||||||||||||||||||||||||
| 525 | = err; | - | ||||||||||||||||||||||||||||||
| 526 | r = 0; | - | ||||||||||||||||||||||||||||||
| 527 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||||||||||||||||||||||||||
| 528 | - | |||||||||||||||||||||||||||||||
| 529 | sh_xfree((tdir), "./cd.def", 670); | - | ||||||||||||||||||||||||||||||
| 530 | return executed 6 times by 1 test: r;return r;Executed by:
executed 6 times by 1 test: return r;Executed by:
| 6 | ||||||||||||||||||||||||||||||
| 531 | } | - | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |