Add newline character to the end of file variable content
What does this MR do and why?
Text file should ends with a newline. how the POSIX standard defines a line:
A sequence of zero or more non- characters plus a terminating character
Therefore, lines not ending in a newline character aren't considered actual lines. That's why some programs have problems processing the last line of a file if it isn't newline terminated.
Relates to :#408413.
User can write content directly to a file,mostly user will forget "\n" since it's invisible in editor page, And Gitlab directly write it to file content which may
some ssh-key will have invalid format due to this issue
cc @daveliu
How to set up and validate locally
-
create a file that contains a line
line1
use
cat -A
(orcat -e
in macOS) to check the file's content it will return
>cat -e test1
line1$
- create a project.
- jump to 'settings > ci_cd > Variables' and create a file variable, something like you can copy content from the file created in step1
4 create a gitlab-ci.yml
to check the file content in pipeline
stages:
build
build:
stage: build
script: cat -A "$ROW"
it returns
which was different than step 1
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.