> ls
test.pl
> perltidy -b -pbp -nst test.pl
> ls
test.pl test.pl.bak
Perlスクリプトの整形コマンドを使いやすいようにコマンドにしてみた。
bin/pbp
#!/bin/bash
#set -u
# man perltidy
# In particular, if you want to use both the -b flag and the -pbp
# (--perl-best-practices) flag, then you must put a -nst flag after the -pbp flag
# because it contains a -st flag as one of its components, which means that output
# will go to the standard output stream.
[ -z "$1" ] && echo "not enough arguments" && exit 1
[ ! -f $1 ] && echo "No such file or directory" && exit 1
perltidy -b -pbp -nst $1
diff -uprN $1.bak $1
example
> cat test.pl
my $aaa = 2;
if ($aaa == 2) {
say $aaa . "abc";
}
> pbp test.pl
--- test.pl.bak 2017-04-29 04:03:25.818000000 +0900
+++ test.pl 2017-04-29 04:26:08.224000000 +0900
@@ -1,4 +1,4 @@
my $aaa = 2;
-if ($aaa == 2) {
+if ( $aaa == 2 ) {
say $aaa . "abc";
}
> ls
test.pl test.pl.bak
参考
Documentation/translations/ja_JP/SubmittingPatches
パッチの作成には「 diff -up 」又は「 diff -uprN 」を使ってください。