Skip to content

Handle special file names.#32

Open
wyhfrank wants to merge 2 commits intodmgerman:masterfrom
wyhfrank:master
Open

Handle special file names.#32
wyhfrank wants to merge 2 commits intodmgerman:masterfrom
wyhfrank:master

Conversation

@wyhfrank
Copy link
Contributor

@wyhfrank wyhfrank commented Jul 5, 2016

Special characters in file name

Files with special characters in their names should be handled correctly now.

Ninka has a module named FileCleaner.pm to clean up input file names with special characters such as ', $, ; and (space). This file name is passed as an argument to external programs (eithercommentsorhead) usingopen3().

However, the command for the external call was constructed by quoting command name and arguments together, for example "head -$count_lines $input_file". In such way, the program will not execute correctly if $input_file contains special characters which are not cleaned up in the previous step (such as < and ().

What I did is split the command name and arguments into an array and pass it to open3(). Now the file names will be handled correctly and we don't need FileCleaner.pm any more, thus removed.

Another minor improvement

Die the program if the input file does not exist, to suppress the error message:

Use of uninitialized value $license_result in concatenation (.) or string at ./bin/ninka line 14.

wyhfrank added 2 commits July 5, 2016 21:28
 * when calling external programs, pass arguments individually instead of quoting them together.
 * remove FileCleaner.pm since it's no longer needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant