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

Show only offending error logs #18

Closed
OmeGak opened this issue May 30, 2015 · 1 comment
Closed

Show only offending error logs #18

OmeGak opened this issue May 30, 2015 · 1 comment

Comments

@OmeGak
Copy link
Owner

OmeGak commented May 30, 2015

Disclaimer. This is thoroughly explained so my future self remember the whole thing when he comes back to the issue I'm about to give up upon for today.

This is gonna be useful for debugging install and *-deps steps of dot command. I want to show at the end of each step the log files of the topics that failed.

My idea is to grep only the log files that contain the name of the failed topic:

find -L /tmp -maxdepth 1 -name *$logfile_suffix | grep '$error_topics'

For grep to grep for several words the following syntax is used:

grep 'a\|b'

Now it should simply be about joining with \| the array errors containing the failed topics, but well, this is Shell, so it's not gonna be so easy, apparently. I first have to resolve to defining a custom function.

function join { local IFS="$1"; shift; echo "$*"; }

This allows me to join the $errors into a string with a separator:

$ echo `join \| ${errors[@]}`
homebrew|whatever

The problem is that there is no way to use \| as separator as IFS only takes the first character | (since \ in the command is used to escape |) and so I have to sed the result to replace | for \|:

$ echo `join \| ${errors[@]}` | sed 's/|/\\|/g'
homebrew\|whatever

So far so good... Let's story this in a variable so that it can be used as initially intended by `grep

error_topics=`join \| ${errors[@]} | sed 's/|/\\|/g'`
echo $error_topics

And the output is:

homebrew|whatever

And I couldn't find any way to store it correctly. :'(

@OmeGak
Copy link
Owner Author

OmeGak commented Jun 23, 2015

Implemented in 99a74da

@OmeGak OmeGak closed this as completed Jun 23, 2015
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

1 participant