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

utils.sh: Remove the tmp output file #3

Merged
merged 3 commits into from
Aug 1, 2024

Conversation

rata
Copy link
Contributor

@rata rata commented Jul 31, 2024

When running a command with run(), we keep the output in a tmp file in /tmp. When a demo runs a lot of commands and you run it several times to fix a thing here and there, it will create a million of tmp files that we don't really need.

This PR just removes the file after we used it.

While I'm there, I've changed the mktemp invocation to not use "-t" that is deprecated and remove the lines added by "script" at the end of the file too, when saving it into $DEMO_RUN_STDOUT.

I've also tried to get rid of script completely and just use something like: DEMO_RUN_STDOUT=$(eval "$*" 2>&1); r=$?. This works fine, but the only issue is that we need to print the output afterwards (as it is stored in that variable), and then the downside is that if the command takes long to run, you don't see anything and then you see it all.

So for long commands it might seem like nothing is happening and that is not nice for demos. But the output is usable in most interactive commands that I tried, so that would be a bonus of that approach.

But let's keep the PR simple for now. Let's just delete the file, that is all we really need for now.

If I need it, in the future I might look into options to add another run function, so commands are printed with colors (like ls -l, but it is not trivial and more dependencies might be needed). But for now just using the command with the explicit option to print colors is enough for me.

rata added 3 commits July 31, 2024 15:33
We don't really need a template if we will just delete a few lines
below. Let's just make it simpler, this creates a file in /tmp, this is
enough.

Signed-off-by: Rodrigo Campos <[email protected]>
Every time we run a command, the log is kept in /tmp. This fills my host
with lot of files. Let's just clean them up after we finished using
them.

Signed-off-by: Rodrigo Campos <[email protected]>
When we run a command with script it also adds lines like:

	Script done on 2024-07-31 13:08:05+02:00 [COMMAND_EXIT_CODE="0"]

at the end. We currently see them in $DEMO_RUN_STDOUT. Let's just skip
them.

Signed-off-by: Rodrigo Campos <[email protected]>
@rata
Copy link
Contributor Author

rata commented Jul 31, 2024

cc @thockin

@thockin thockin merged commit b8af014 into thockin:master Aug 1, 2024
1 check passed
@rata rata deleted the run-no-output-file branch August 1, 2024 15:56
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.

2 participants