brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Graeme-Miller <...@git.apache.org>
Subject [GitHub] brooklyn-server issue #554: Ensured the \n character is escaped when escapin...
Date Thu, 09 Feb 2017 14:35:17 GMT
Github user Graeme-Miller commented on the issue:

    https://github.com/apache/brooklyn-server/pull/554
  
    @aledsage has pointed out a way to get around the problem I am having, so I no longer
need this PR. However, I think it might still be useful
    
    @neykov, the use case here is that I have brooklyn.config like this:
    ```
    brooklyn.config:
      brooklyn.cfg.additions: |
        brooklyn.location.jclouds.aws-ec2.identity = test_ident
        brooklyn.location.jclouds.aws-ec2.credential = test_key
    ```
    Brooklyn sets the config to be 
    
    ```
    brooklyn.location.jclouds.aws-ec2.identity = test_ident\nbrooklyn.location.jclouds.aws-ec2.credential
= test_key
    ```
    (please note '\n' is a character, not a '\\' followed by an 'n'. If you use a '\\' followed
by an 'n' this works)
    
    I later pump this config into a bash env variable like this:
    ```
    shell.env:
      BROOKLYN_CFG_ADDITIONS: $brooklyn:config("brooklyn.cfg.additions")
    ```
    
    However, when the string is bash encoded, the '\n' is not encoded. My script then ends
up looking like this:
    ```
    BROOKLYN_CFG_ADDITIONS="brooklyn.location.jclouds.aws-ec2.identity = test_ident
    brooklyn.location.jclouds.aws-ec2.credential = test_key"
    ```
    
    Which means the \n is used to create a line break in the script (which does nothing) rather
than keeping the \n in the variable.
    
    Changing this bash encoding means my script ends up looking like this:
    ```
    BROOKLYN_CFG_ADDITIONS="brooklyn.location.jclouds.aws-ec2.identity = test_ident\nbrooklyn.location.jclouds.aws-ec2.credential
= test_key"
    ```
    
    
    Whilst Aleds suggestion will work, I worry others might try to use multi line bash config
in the same way that I did.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message