Skip to content

Issue with php code sniffer 2.6.0 in a bash script "while read..." #953

@neilime

Description

@neilime

Hi,

I got an issue with this bash script : execute php code sniffer for several php files. I don't have this issue with php code sniffer 2.5.1.

#!/bin/bash FILES=$(echo -e "test1.php\ntest2.php"); echo -e "\e[94m\n # Old version Check "`echo "$FILES" | wc -l`" file(s) :\n\e[0m"; while read FILE; do echo -e "Process file \"$FILE\"\n" php php-code-sniffer/2.6.0/scripts/phpcbf "$FILE" done <<< "$FILES";

Output :

Process file "test1.php" Changing into directory test Processing test.php [PHP => 82 tokens in 21 lines]... DONE in 7ms (0 fixable violations) Processing STDIN [PHP => 1 tokens in 1 lines]... DONE in 0ms (0 fixable violations) No fixable errors were found Time: 30ms; Memory: 7.25Mb

Only the first file is processed by php code sniffer.

If I use this script :

#!/bin/bash FILES=$(echo -e "test1.php\ntest2.php"); echo -e "\e[94m\n # New version Check "`echo "$FILES" | wc -l`" file(s) :\n\e[0m"; old_IFS=$IFS IFS=$'\n' for FILE in $FILES do echo -e "Process file \"$FILE\"\n" php php-code-sniffer/2.6.0/scripts/phpcbf "$FILE" done; IFS=$old_IFS

Output :

 # New version Check 2 file(s) : Process file "test1.php" Changing into directory /.../test_repository Processing test.php [PHP => 82 tokens in 21 lines]... DONE in 7ms (0 fixable violations) No fixable errors were found Time: 30ms; Memory: 7.25Mb Process file "test2.php" Changing into directory /.../test_repository Processing test.php [PHP => 82 tokens in 21 lines]... DONE in 8ms (0 fixable violations) No fixable errors were found Time: 31ms; Memory: 7.25Mb

It works !

Maybe this tricks can help someone and maybe this issue can be fixed too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions