picongpu icon indicating copy to clipboard operation
picongpu copied to clipboard

TBG variable wrong but no error

Open macdre141 opened this issue 7 years ago • 12 comments

When using the following tbg variable

TBG_radiation="--eG_radiation.period 1 --eG_radiation.dump 100 \
               --eG_radiation.totalRadiation   \
               --eG_radiation.lastRadiation 
               --e_radiation.start 20000 --e_radiation.end 40000 "

with a missing \ in third line, tbg still creates an output file but without the fourth line and it didn't throw and error.

macdre141 avatar Oct 26 '18 13:10 macdre141

@macdre141 Welcome to GitHub and PIConGPU! Thanks for committing your first issue :+1:.

@psychocoderHPC Is this the intended behavior of tbg?

PrometheusPi avatar Oct 26 '18 13:10 PrometheusPi

Hm, complicated. That's just "bash" and a similar

#!/usr/bin/env bash

TBG_radiation="--eG_radiation.period 1 --eG_radiation.dump 100 \
               --eG_radiation.totalRadiation   \
               --eG_radiation.lastRadiation 
               --e_radiation.start 20000 --e_radiation.end 40000 "

echo $TBG_radiation

does indeed output

--eG_radiation.period 1 --eG_radiation.dump 100 --eG_radiation.totalRadiation --eG_radiation.lastRadiation --e_radiation.start 20000 --e_radiation.end 40000

ax3l avatar Oct 30 '18 08:10 ax3l

Also, your last line

--e_radiation.start 20000 --e_radiation.end 40000

has an error e instead of eG which is something tbg cannot catch since it's a logic bug.

ax3l avatar Oct 30 '18 08:10 ax3l

Hm, complicated. That's just "bash" and a similar

#!/usr/bin/env bash

TBG_radiation="--eG_radiation.period 1 --eG_radiation.dump 100 \
               --eG_radiation.totalRadiation   \
               --eG_radiation.lastRadiation 
               --e_radiation.start 20000 --e_radiation.end 40000 "

echo $TBG_radiation

does indeed output

--eG_radiation.period 1 --eG_radiation.dump 100 --eG_radiation.totalRadiation --eG_radiation.lastRadiation --e_radiation.start 20000 --e_radiation.end 40000

Even if this works with normal bash I am not sure if we can handle it in tbg. The problem is that we need to detect multi line arguments and transform them internally. We should keep this issue open but I give it a low priority since it is an ill formatted input.

psychocoderHPC avatar Oct 30 '18 09:10 psychocoderHPC

@ax3l Yes, there is a bug in there that should have caused a crash at start time - but thus it ran (without the extra flags).

PrometheusPi avatar Oct 30 '18 09:10 PrometheusPi

The question is also a bit why we even need the \. Pure bash does not need line-continuation to define multi-line strings. (And it's a common source of error for our users.)

#!/usr/bin/env bash

A="Hey,
   hey yo,
     hey jo!"

echo $A
Hey, hey yo, hey jo!

ax3l avatar Oct 31 '18 11:10 ax3l

I do not remember why. We can check if we can skip the backslash

Am 31. Oktober 2018 12:45:03 MEZ schrieb Axel Huebl [email protected]:

The question is also a bit why we even need the \. Pure bash does not need line-continuation to define multi-line strings. (And it's a common source of error for our users.)

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/ComputationalRadiationPhysics/picongpu/issues/2775#issuecomment-434656625

psychocoderHPC avatar Oct 31 '18 11:10 psychocoderHPC

@macdre141 may I ask you for a little favor? Since you are PIConGPU pro's now and we are trying to run as well on Stampede2, can you please add yourselves to our community map? :) Thanks a lot! cc @n01r (live map)

ax3l avatar Nov 18 '18 17:11 ax3l

For future reference (and because I am too lazy to add a documentation section):

The snippet you are looking for is the following:


var_with_newlines="
--option1
--option2 arg
"

# replace newlines by spaces, see sed(1)
TBG_var=$(sed -z 's/\n/ /g' <<< "$var_with_newlines")

s9105947 avatar Mar 24 '22 09:03 s9105947

@psychocoderHPC will you implement such a sed code into tbg - otherwise we should perhaps close this issue?

PrometheusPi avatar Apr 20 '22 18:04 PrometheusPi

Oh I would +1 for implementing it or printing a warning, got hurt by it today

sbastrakov avatar Apr 20 '22 18:04 sbastrakov

@psychocoderHPC ping?

BrianMarre avatar May 04 '23 13:05 BrianMarre