Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml multiline strings #401

Open
smichel17 opened this issue Jan 3, 2020 · 2 comments
Open

yaml multiline strings #401

smichel17 opened this issue Jan 3, 2020 · 2 comments

Comments

@smichel17
Copy link
Contributor

Yaml multiline strings appear to incorrectly drop line breaks in some places. This is important because it limits the ability to embed scripts in a readable manner (there is currently only one way I'm comfortable embedding scripts, and it makes them completely unreadable in the installer). Minimum example:

Add to installer:

- write_file:
    content: '#!/bin/sh

      fullscreen() {
          cd "$gamedir/game"
          ./NecroDancer.sh 1
      }'
    file: $GAMEDIR/run.sh

Expected: Stays the same upon save
Actual: Becomes

- write_file:
    content: '#!/bin/sh

      fullscreen() { cd "$gamedir/game" ./NecroDancer.sh 1 }'
    file: $GAMEDIR/run.sh

Current workaround: Add an extra line break in problematic places (double spaced), like so:

- write_file:
    content: '#!/bin/sh

      fullscreen() {

          cd "$gamedir/game"

          ./NecroDancer.sh 1

      }'
    file: $GAMEDIR/run.sh
@smichel17
Copy link
Contributor Author

smichel17 commented Jan 3, 2020

there is currently only one way I'm comfortable embedding scripts

The way being block scalars (> or |), and the problem being that they're converted to double-quoted flow scalars with \n for newlines, which results in scripts like this (truncated):

- write_file:
    content: "#!/usr/bin/env sh\n\n# If abi.vsyscall32=0 is already set, no need to\
      \ do anything\nif [ \"$(cat /proc/sys/abi/vsyscall32)\" -eq 0 ]; then\n    exit\
      \ 0\nfi\n\ndialog() {\n    zenity \"$@\" --icon-name='lutris' --width=\"400\"\
      \ --title=\"League of Legends anticheat compatibility check\"\n}\n\nfinal_check()\
      \ {\n    if [ \"$(cat /proc/sys/abi/vsyscall32)\" -ne 0 ]; then\n        dialog\
      \ --warning --text=\"As far as this script can detect, your system is not configured\
      \ to work with League's anticheat. Please verify that you can get into the practice\
      \ too before playing a multiplayer game.\"\n    fi\n}\n\ntrap final_check EXIT\n\
      \nif grep -E -x -q \"abi.vsyscall32( )?=( )?0\" /etc/sysctl.conf; then\n   \
      \ if dialog --question --text=\"It looks like you already configured your system\
      \ to work with League anticheat, and saved the setting to persist across reboots.\
      \ However, for some reason the persistence part did not work.\\n\\nFor now,\
      \ would you like to enable the setting again until the next reboot?\"\n    then\n\
      \        pkexec sh -c 'sysctl -w abi.vsyscall32=0'\n    fi\n    exit 0\nfi\n\

@TriMoon
Copy link

TriMoon commented Jul 19, 2023

Maybe instead of:

- write_file:
    content: '#!/bin/sh

      fullscreen() {
          cd "$gamedir/game"
          ./NecroDancer.sh 1
      }'
    file: $GAMEDIR/run.sh

One should terminate the lines with commands after them with a semicolon, so they parse correctly? 🤔
Note the semicolon at the cd line, it's unneeded but harmless to add semicolons after every command-line... (See man your shell)

- write_file:
    content: '#!/bin/sh

      fullscreen() {
          cd "$gamedir/game";
          ./NecroDancer.sh 1
      }'
    file: $GAMEDIR/run.sh

This would/should become:

- write_file:
    content: '#!/bin/sh

      fullscreen() { cd "$gamedir/game"; ./NecroDancer.sh 1 }'
    file: $GAMEDIR/run.sh

🖖

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants