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

Use CSV formatting instead of custom colon-separated + base64 encoded #26

Open
pawamoy opened this issue May 1, 2019 · 0 comments
Open
Labels
fund Issue priority can be boosted refactor Change suggestion, not a bug nor a feature.

Comments

@pawamoy
Copy link
Owner

pawamoy commented May 1, 2019

The idea is to make the history file more readable for humans, but also easily importable by other tools.

I don't think there's a library for handling CSV files in Bash, and even if there was, I think it would slow down things a lot, which we don't want because shellhistory happens in interactive shells and we cannot let users wait for more than 200ms between each command. Appending a line to the history file must be as fast as possible.

But the CSV formatting is not hard either, so we could do it by hand. If I remember correctly, you can use any delimiter you want, as long as fields that contain it are enclosed in double-quotes. If these same fields also contain double-quotes, then you must simply double these.

Example with a comma as delimiter:

field 1,,field 3,"hey, I'm field 4!",,"he said ""4""? alright, then I'm gonna say ""6""!",field 7

Same string imported in GNumeric:

Screenshot_2019-05-01_15-58-35

It's working, yay!

So instead of encoding parents and working directory in base 64, we could simply enclose them in double-quotes, and use some sed 's/"/""/g on it. And instead of prepending a colon on normal lines, and a semi-colon on extra command lines, we could also simply do the same for the command.

:...:echo "a
;b
;c" | wc -c

would become

...:"echo ""a
b
c"" | wc -c"

Also, just to make sure, we could also enclose hostname and user in double-quotes.

Boost priority

  • Boost priority in our backlog through Polar.sh. Higher pledge, higher priority.
  • Minimum pledge by user/organization is $5, minimum amount for boost is $30.
  • View all issues with pledges.
  • We receive the funds once the issue is completed and confirmed by you.
  • Features with the insiders label are released to sponsors first, and tied to a funding goal.
Fund with Polar
@pawamoy pawamoy added refactor Change suggestion, not a bug nor a feature. fund Issue priority can be boosted labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fund Issue priority can be boosted refactor Change suggestion, not a bug nor a feature.
Projects
None yet
Development

No branches or pull requests

1 participant