Bash 还有另一个问题是。/../public/test。这个问题是一系列密切相关的问题之一,如果不是重复的话:。 your_path=../test/test test_path=../../public/test file_input="$1" #wh

Bash 还有另一个问题是。/../public/test。这个问题是一系列密切相关的问题之一,如果不是重复的话:。 your_path=../test/test test_path=../../public/test file_input="$1" #wh,bash,shell,scripting,compilation,command,Bash,Shell,Scripting,Compilation,Command,还有另一个问题是。/../public/test。这个问题是一系列密切相关的问题之一,如果不是重复的话:。 your_path=../test/test test_path=../../public/test file_input="$1" #while read -r line; do #done < "$file_input" # Read contents in the file contents=$(< "$file_input") # Display output


还有另一个问题是
。/../public/test
。这个问题是一系列密切相关的问题之一,如果不是重复的话:。
your_path=../test/test
test_path=../../public/test    
file_input="$1"
#while read -r line; do
#done < "$file_input"

# Read contents in the file
contents=$(< "$file_input")
# Display output of the test file
"$test_path" $contents > correctanswer 2>&1
# Display output of your file
"$your_path" $contents > youranswer 2>&1
diff the solutions
diff correctanswer youranswer > /dev/null 2>&1
if [ $? -eq 0 ]
then
  echo "The two outputs were exactly the same "
else
  echo "$divider"
  echo "The two outputs were different "
  diff youranswer correctanswer
  echo "Do you wish to see the ouputs side-by-side?"
      select yn in "Yes" "No"; do
      case $yn in
         Yes ) echo "LEFT: Your Output   RIGHT: Solution Output"
               sleep 1
               vimdiff youranswer correctanswer; break;;
         No ) exit;;
      esac
      done
fi
your_path=../test/test
test_path=../../public/test    
file_input="$1"
while read -r -u 3 contents
do
    # Display output of the test file
    "$test_path" $contents > correctanswer 2>&1
    # Display output of your file
    "$your_path" $contents > youranswer 2>&1
    # diff the solutions
    diff correctanswer youranswer > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        echo "The two outputs were exactly the same "
    else
        echo "$divider"
        echo "The two outputs were different "
        diff youranswer correctanswer
        echo "Do you wish to see the ouputs side-by-side?"
        select yn in "Yes" "No"; do
            case $yn in
                Yes)  echo "LEFT: Your Output   RIGHT: Solution Output"
                      sleep 1
                      vimdiff youranswer correctanswer
                      break;;
                 No)  exit;;
            esac
        done
    fi
done 3< "$file_input"
printf "%s\n" "$@"
printf "%s\n" "1$@2"
9 11 22 13
2 35 32 16
$ bash -x botched.sh input.file
+ '[' -f /etc/bashrc ']'
+ . /etc/bashrc
++ '[' -z '' ']'
++ return
+ alias 'r=fc -e -'
+ your_path=./test1
+ test_path=./test2
+ file_input=input.file
+ read -r -u 3 contents
+ ./test2 9 11 22 13
+ ./test1 9 11 22 13
+ diff correctanswer youranswer
+ '[' 0 -eq 0 ']'
+ echo 'The two outputs were exactly the same '
The two outputs were exactly the same 
+ read -r -u 3 contents
+ ./test2 2 35 32 16
+ ./test1 2 35 32 16
+ diff correctanswer youranswer
+ '[' 0 -eq 0 ']'
+ echo 'The two outputs were exactly the same '
The two outputs were exactly the same 
+ read -r -u 3 contents
$
$ bash -x botched.sh input.file
+ '[' -f /etc/bashrc ']'
+ . /etc/bashrc
++ '[' -z '' ']'
++ return
+ alias 'r=fc -e -'
+ your_path=./test1
+ test_path=./test2
+ file_input=input.file
+ read -r -u 3 contents
+ ./test2 9 11 22 13
+ ./test1 9 11 22 13
+ diff correctanswer youranswer
+ '[' 1 -eq 0 ']'
+ echo ''

+ echo 'The two outputs were different '
The two outputs were different 
+ diff youranswer correctanswer
1c1
< 9
---
> 19
4c4
< 13
---
> 132
+ echo 'Do you wish to see the ouputs side-by-side?'
Do you wish to see the ouputs side-by-side?
+ select yn in '"Yes"' '"No"'
1) Yes
2) No
#? 1
+ case $yn in
+ echo 'LEFT: Your Output   RIGHT: Solution Output'
LEFT: Your Output   RIGHT: Solution Output
+ sleep 1
+ vimdiff youranswer correctanswer
2 files to edit
+ break
+ read -r -u 3 contents
+ ./test2 2 35 32 16
+ ./test1 2 35 32 16
+ diff correctanswer youranswer
+ '[' 1 -eq 0 ']'
+ echo ''

+ echo 'The two outputs were different '
The two outputs were different 
+ diff youranswer correctanswer
1c1
< 2
---
> 12
4c4
< 16
---
> 162
+ echo 'Do you wish to see the ouputs side-by-side?'
Do you wish to see the ouputs side-by-side?
+ select yn in '"Yes"' '"No"'
1) Yes
2) No
#? 2
+ case $yn in
+ exit
$
your_path=./test1 #../test/test
test_path=./test2 #../../public/test    
file_input="$1"
while read -r -u 3 contents
do
    # Display output of the test file
    "$test_path" $contents > correctanswer 2>&1
    # Display output of your file
    "$your_path" $contents > youranswer 2>&1
    # diff the solutions
    diff correctanswer youranswer > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
        echo "The two outputs were exactly the same "
    else
        echo "$divider"
        echo "The two outputs were different "
        diff youranswer correctanswer
        echo "Do you wish to see the ouputs side-by-side?"
        select yn in "Yes" "No"; do
            case $yn in
                Yes)  echo "LEFT: Your Output   RIGHT: Solution Output"
                      sleep 1
                      vimdiff youranswer correctanswer
                      break;;
                 No)  exit;;
            esac
        done
    fi
done 3< "$file_input"
your_path=../test/test
test_path=../../public/test    
file_input="$1"

exec 3< $file_input
while read -u 3 l; do
# do your per-test diffs and outputs here
# variable $l will contain one line of $file_input
    # Display output of the test file
    "$test_path" $l > correctanswer 2>&1
    # Display output of your file
    "$your_path" $l > youranswer 2>&1
    # diff the solutions
    diff correctanswer youranswer > /dev/null 2>&1
    if [ $? -eq 0 ]
    then
      echo "The two outputs were exactly the same "
    else
      echo "$divider"
      echo "The two outputs were different "
      diff youranswer correctanswer
      echo "Do you wish to see the ouputs side-by-side?"
          select yn in "Yes" "No"; do
          case $yn in
             Yes ) echo "LEFT: Your Output   RIGHT: Solution Output"
                   sleep 1
                   vimdiff youranswer correctanswer; break;;
             No ) exit;;
          esac
          done
    fi

done