Try this ... create a file called "bash -is-odd.sh":
#!/bin/bash echo "echo yes i do odd things" >> bash-is-odd.sh
This demonstrates that bash really interprets the "when you go" script. Indeed, editing a long-term script has unpredictable results, inserting random characters, etc. Why? Since bash reads from the last byte position, so editing changes the location of the current character that is being read.
Bash, in a word, is very, very dangerous because of this "function". svn and rsync when used with bash scripts are especially troubling because by default they "combine" the results ... in-place editing. Rsync has a mode that fixes this. svn and git not.
I present a solution. Create a file called "/ bin / bashx":
#!/bin/bash source "$1"
Now use #! / Bin / bashx in your scripts and always run them with "bashx" instead of bash. This fixes the problem - you can safely rsync your scripts.
Alternative (built-in) solution proposed / tested with @ AF7:
{
Paste brackets protect against editing, and output protects against adding. Of course, we would be much better if bash came with an option, for example, "-w" (the whole file) or something like that.
Erik Aronesty Oct 17 '13 at 15:28 2013-10-17 15:28
source share