Git Product home page Git Product logo

Comments (4)

galpeter avatar galpeter commented on May 23, 2024

For this there is two solutions:

  1. enclose the variable used during the transformation:
diff --git a/tools/generator.sh b/tools/generator.sh
index e020fe0..66c0754 100755
--- a/tools/generator.sh
+++ b/tools/generator.sh
@@ -17,7 +17,7 @@
 echo "#define JERRY_MCU_SCRIPT \\" > $2
 cat $1 | while read line
 do
-  line=$(echo $line | sed 's/"/\\"/g')
+  line=$(echo "$line" | sed 's/"/\\"/g')
   echo "\"$line\n\" \\" >> $2
 done
 echo >> $2
  1. Rewrite the whole thing with sed:
diff --git a/tools/generator.sh b/tools/generator.sh
index e020fe0..ee0ff47 100755
--- a/tools/generator.sh
+++ b/tools/generator.sh
@@ -15,9 +15,5 @@
 # limitations under the License.

 echo "#define JERRY_MCU_SCRIPT \\" > $2
-cat $1 | while read line
-do
-  line=$(echo $line | sed 's/"/\\"/g')
-  echo "\"$line\n\" \\" >> $2
-done
+sed 's/"/\\"/g' $1 | sed 's/^.*$/"\0" \\/g' >> $2
 echo >> $2

There will be a bit difference in the 2nd case as it will leave any trailing/leading whitespaces intact.

Which solution would be better?

from jerryscript.

ruben-ayrapetyan avatar ruben-ayrapetyan commented on May 23, 2024

@galpeter ,
it seems that leaving whitespaces exactly as they were in source script is better.

from jerryscript.

egavrin avatar egavrin commented on May 23, 2024

BTW, if someone can propose the better solution than usage of this script, I'd prefer it.

from jerryscript.

egavrin avatar egavrin commented on May 23, 2024

Fix is merged as #200

from jerryscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.