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

csvtools dependency #22

Open
kiteloopdesign opened this issue Apr 24, 2022 · 8 comments
Open

csvtools dependency #22

kiteloopdesign opened this issue Apr 24, 2022 · 8 comments

Comments

@kiteloopdesign
Copy link

Hi, this is not a big deal and can be easily done manually but I like script resolve.sh and I'd like to make use of it. It is however dependant on csvtool binary, which is not available on Fedora. There is a number of csv processing tools out there, so I fail to see which one is being used here? I believe it may be this one?

https://colin.maudry.com/csvtool-manual-page/

In any case, I think it would make sense to use awk to process columns to make have less dependencies? (script already makes use of sk -By the way, fzf can be used as a drop-in tool)

@kiteloopdesign
Copy link
Author

update: csvtool is provided in fedora via ocaml-csv package

@adept
Copy link
Owner

adept commented May 1, 2022

Sorry for not answering earlier. Yes, this is the right csvtool. I would be happy to hear about good (and maybe more widespread) substitutes, but unfortunately awk is not one. You can't easily make awk recognize ""-quoting and embedded commas, so it will break on any even slightly sophisticated csv file -- unless you happen to use exotic delimiters like | or @ or something that is entirely absent from the data values

@ratoru
Copy link

ratoru commented Sep 5, 2024

Hey there!
I rewrote resolve.sh to use fzf, ripgrep, and miller instead of sk and csvtool.
You can find the script here: resolve gist. I've only tested it on macOS so far.

Maybe it's an option for those that don't have csvtool. Hope some of you find it useful!

@adept
Copy link
Owner

adept commented Sep 10, 2024

Thank you for introducing me to miller! This looks very useful (and prettier than what I have now). I'll take some time to review and most likely end up incorporating your changes.

Thank you very much for sharing!

@ratoru
Copy link

ratoru commented Sep 15, 2024

I'm glad!

I just updated the gist with some better error handling if you do not have a .rules file.

I'm not sure if the script handles file-specific rules as introduced in Chapter 12, though.

@austinletson
Copy link

Thanks @ratoru for writing this updated resolve.sh script. I appreciate the ability to add a new account by pretending :.

I have a question though. Why did you change $(ls ${dir}/*.rules | paste -s -d' ') in the original resolve.sh to this:

        rules=$(
            for file in ${dir}/*.rules; do
                # Ignore comments, since they break fzf call
                grep -v '^#' "$file"
            done | paste -s -d ' ' -
        )

This breaks the rg command for my rules file. It seems like it passes every line of the rules file to rg instead of just the file name. Your new script works great if I switch back to the original method like this:

rules=$(ls ${dir}/*.rules | paste -s -d' ')

@ratoru
Copy link

ratoru commented Sep 16, 2024

Ah interesting! There was a bug with my previous version, that I tried to fix by introducing another bug. Thank you for catching it @austinletson!

rules=$(ls ${dir}/*.rules | paste -s -d' ') doesn't run on my system, so I wrote a buggy workaround. The right version should be rules=$(ls ${dir}/*.rules | paste -s -d' ' -). Updated the gist accordingly.

@austinletson
Copy link

Ah, I see. Thanks again!

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

No branches or pull requests

4 participants