Note that there are some explanatory texts on larger screens.

plurals
  1. POBash: Concatenating strings fails when read from certain files
    primarykey
    data
    text
    <p>I have a web application that is deployed to a server. I am trying to create a script that amoing other things reads the current version of the web application from a properties file that is deployed along with the application.</p> <p>The file looks like this:</p> <pre><code>//other content version=[version number] build=[buildnumber] //other content </code></pre> <p>I want to create a variable that looks like this: <code>version-buildnumber</code></p> <p>Here is my script for it:</p> <pre><code>VERSION_FILE=myfile VERSION_LINE="$(grep "version=" $VERSION_FILE)" VERSION=${VERSION_LINE#$"version="} BUILDNUMBER_LINE=$(grep "build=" $VERSION_FILE) BUILDNUMBER=${BUILDNUMBER_LINE#$"build="} THEVERSION=${VERSION}-${BUILDNUMBER} </code></pre> <p>The strange thing is that this works in some cases but not in others. The problem I get is when I am trying to concatenate the strings (i.e. the last line above). In some cases it works perfectly, but in others characters from one string replace the characters from the other instead of being placed afterwards.</p> <p>It does <strong>not</strong> work in these cases:</p> <ul> <li>When I read from the deployed file</li> <li>If I copy the deployed file to another location and read from there</li> </ul> <p>It <strong>does</strong> work in these cases:</p> <ul> <li>If I write a file from scratch and read from that one.</li> <li>If I create my own file and then copy the content from the deployed file into my created file.</li> </ul> <p>I find this very strange. Is there someone out there recognizing this?</p> <p>/Ludwig</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload