[Ttssh2-commit] [6644] ・オプションの扱いを厳密にした

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2017年 3月 22日 (水) 18:19:45 JST


Revision: 6644
          http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6644
Author:   doda
Date:     2017-03-22 18:19:44 +0900 (Wed, 22 Mar 2017)
Log Message:
-----------
・オプションの扱いを厳密にした
・coding, lf を指定しなかった場合のデフォルトを設定
・ヘルプメッセージを出力するようにした

Modified Paths:
--------------
    trunk/installer/2sjis.pl

-------------- next part --------------
Modified: trunk/installer/2sjis.pl
===================================================================
--- trunk/installer/2sjis.pl	2017-03-20 15:31:21 UTC (rev 6643)
+++ trunk/installer/2sjis.pl	2017-03-22 09:19:44 UTC (rev 6644)
@@ -4,14 +4,23 @@
 use strict;
 use Encode;
 use utf8;
-use Getopt::Long;
+use Getopt::Long qw(:config posix_default no_ignore_case gnu_compat);
 
 my($in, $out, $coding, $lf, $result);
-$result = GetOptions('in=s'     => \$in,
-                     'out=s'    => \$out,
-                     'coding=s' => \$coding,
-                     'lf=s'     => \$lf);
 
+# default setting
+$coding = "shiftjis";
+$lf = "crlf";
+
+$result = GetOptions('in|i=s'     => \$in,
+                     'out|o=s'    => \$out,
+                     'coding|c=s' => \$coding,
+                     'lf|l=s'     => \$lf);
+
+if (!(defined($in) && defined($out))) {
+	die "Usage: $0 --in file --out file [ --coding input_encoding ] [ --lf line_format ]\n";
+}
+
 open (IN,  "<:$lf:encoding($coding)",   $in);
 open (OUT, '>:crlf:encoding(shiftjis)', $out);
 while (<IN>) {



Ttssh2-commit メーリングリストの案内
Back to archive index