【问题标题】:What does the "-Np1" option for the patch command do?patch 命令的“-Np1”选项有什么作用?
【发布时间】:2021-09-09 03:15:44
【问题描述】:

有人给我发了一个补丁并告诉我使用以下命令应用它:

patch -Np1 -i file.patch

出于好奇,我试图找出 -Np1 选项的作用,但补丁手册页对此非常不透明。谁能解释这是做什么的?谢谢。

【问题讨论】:

  • 是-N和-p1的组合。

标签: unix patch


【解决方案1】:

这是两个标志。 -N-p1

   -N  or  --forward
      Ignore patches that seem to be reversed  or  already  applied.   See
      also -R.

   -pnum  or  --strip=num
      Strip the smallest prefix containing num leading slashes  from  each
      file  name found in the patch file.  A sequence of one or more adja-
      cent slashes is counted as a single slash.  This controls  how  file
      names  found  in  the  patch file are treated, in case you keep your
      files in a different directory than the  person  who  sent  out  the
      patch.  For example, supposing the file name in the patch file was

         /u/howard/src/blurfl/blurfl.c

      setting -p0 gives the entire file name unmodified, -p1 gives

         u/howard/src/blurfl/blurfl.c

      without the leading slash, -p4 gives

         blurfl/blurfl.c

      and  not specifying -p at all just gives you blurfl.c.  Whatever you
      end up with is looked for either in the current  directory,  or  the
      directory specified by the -d option.

【讨论】:

    猜你喜欢
    • 2012-03-20
    • 1970-01-01
    • 1970-01-01
    • 2015-02-05
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多