Skip to content

Skip trailing newline when printing token to a terminal#31

Open
LRitzdorf wants to merge 2 commits into
OpenCHAMI:mainfrom
LRitzdorf:lritzdorf/no-newline-when-not-terminal
Open

Skip trailing newline when printing token to a terminal#31
LRitzdorf wants to merge 2 commits into
OpenCHAMI:mainfrom
LRitzdorf:lritzdorf/no-newline-when-not-terminal

Conversation

@LRitzdorf

Copy link
Copy Markdown

Description

When printing user tokens (i.e. user-token create), a trailing newline is included to make terminal output cleaner. This is usually fine, but some automations take the raw output (including newline) and pass it to other tools that might not expect it, e.g. curl (which gets mad when you try to include a newline in a header field).

This behavior was hidden for a while since bash's command substitution strips the newline; you need to be working in a semi-low-level language to actually pass it on to other commands down the chain.

Also, I've applied a similar fix to bootstrap-token create's JSON output mode in particular. Most tools parsing the JSON will probably be fine with a newline, but omitting it certainly can't hurt.

Fixes #30

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

I don't actually have a working OpenCHAMI environment on hand, so I can't immediately test this. It'd be appreciated if someone else could check that nothing explodes as a result :)

Signed-off-by: Lucas Ritzdorf <42657792+LRitzdorf@users.noreply.github.com>
Signed-off-by: Lucas Ritzdorf <42657792+LRitzdorf@users.noreply.github.com>
@LRitzdorf LRitzdorf force-pushed the lritzdorf/no-newline-when-not-terminal branch from 3cb2314 to 383ca0f Compare June 24, 2026 23:25
@LRitzdorf

Copy link
Copy Markdown
Author

This is what I get for using a more recent version of Go locally...

@alexlovelltroy alexlovelltroy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks very reasonable here, but I haven't had a chance to test anywhere.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]:

2 participants