Print this page
667 cp support for -a flag

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mv/mv.c
          +++ new/usr/src/cmd/mv/mv.c
↓ open down ↓ 174 lines elided ↑ open up ↑
 175  175                  cpy = TRUE;
 176  176          else {
 177  177                  (void) fprintf(stderr,
 178  178                      gettext("Invalid command name (%s); expecting "
 179  179                      "mv, cp, or ln.\n"), cmd);
 180  180                  exit(1);
 181  181          }
 182  182  
 183  183          /*
 184  184           * Check for options:
 185      -         *      cp  -r|-R [-H|-L|-P] [-fip@/] file1 [file2 ...] target
 186      -         *      cp [-fiprR@/] file1 [file2 ...] target
      185 +         *      cp [ -r|-R [-H|-L|-P]] [-afip@/] file1 [file2 ...] target
      186 +         *      cp [-afiprR@/] file1 [file2 ...] target
 187  187           *      ln [-f] [-n] [-s] file1 [file2 ...] target
 188  188           *      ln [-f] [-n] [-s] file1 [file2 ...]
 189  189           *      mv [-f|i] file1 [file2 ...] target
 190  190           *      mv [-f|i] dir1 target
 191  191           */
 192  192  
 193  193          if (cpy) {
 194      -                while ((c = getopt(argc, argv, "fHiLpPrR@/")) != EOF)
      194 +                while ((c = getopt(argc, argv, "afHiLpPrR@/")) != EOF)
 195  195                          switch (c) {
 196  196                          case 'f':
 197  197                                  fflg++;
 198  198                                  break;
 199  199                          case 'i':
 200  200                                  iflg++;
 201  201                                  break;
 202  202                          case 'p':
 203  203                                  pflg++;
 204  204  #ifdef XPG4
↓ open down ↓ 26 lines elided ↑ open up ↑
 231  231                                  /*
 232  232                                   * The default behavior of cp -R|-r
 233  233                                   * when specified without -H|-L|-P
 234  234                                   * is -L.
 235  235                                   */
 236  236                                  Rflg++;
 237  237                                  /*FALLTHROUGH*/
 238  238                          case 'r':
 239  239                                  rflg++;
 240  240                                  break;
      241 +                        case 'a':
      242 +                                Lflg = Hflg = 0;
      243 +                                pflg++;
      244 +                                Pflg++;
      245 +                                Rflg++;
      246 +                                rflg++;
      247 +                                break;
 241  248                          case '@':
 242  249                                  atflg++;
 243  250                                  attrsilent = 0;
 244  251  #ifdef XPG4
 245  252                                  pflg = 0;
 246  253  #endif
 247  254                                  break;
 248  255                          case '/':
 249  256                                  saflg++;
 250  257                                  attrsilent = 0;
↓ open down ↓ 1065 lines elided ↑ open up ↑
1316 1323                      "       ln [-f] [-s] f1 ... fn d1\n"
1317 1324                      "       ln [-f] -s d1 d2\n"));
1318 1325  #else
1319 1326                  (void) fprintf(stderr, gettext(
1320 1327                      "Usage: ln [-f] [-n] [-s] f1 [f2]\n"
1321 1328                      "       ln [-f] [-n] [-s] f1 ... fn d1\n"
1322 1329                      "       ln [-f] [-n] -s d1 d2\n"));
1323 1330  #endif
1324 1331          } else if (cpy) {
1325 1332                  (void) fprintf(stderr, gettext(
1326      -                    "Usage: cp [-f] [-i] [-p] [-@] [-/] f1 f2\n"
1327      -                    "       cp [-f] [-i] [-p] [-@] [-/] f1 ... fn d1\n"
1328      -                    "       cp -r|-R [-H|-L|-P] [-f] [-i] [-p] [-@] [-/] "
1329      -                    "d1 ... dn-1 dn\n"));
     1333 +                    "Usage: cp [-a] [-f] [-i] [-p] [-@] [-/] f1 f2\n"
     1334 +                    "       cp [-a] [-f] [-i] [-p] [-@] [-/] f1 ... fn d1\n"
     1335 +                    "       cp [-r|-R [-H|-L|-P]] [-a] [-f] [-i] [-p] [-@] "
     1336 +                    "[-/] d1 ... dn-1 dn\n"));
1330 1337          }
1331 1338          exit(2);
1332 1339  }
1333 1340  
1334 1341  /*
1335 1342   * chg_time()
1336 1343   *
1337 1344   * Try to preserve modification and access time.
1338 1345   * If 1) pflg is not set, or 2) pflg is set and this is the Solaris version,
1339 1346   * don't report a utimensat() failure.
↓ open down ↓ 911 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX