Comments (6)
I'll look into how I could achieve this without making a mess.
My first thought (without reading up on it) would be to try to set the colors as variables - and if the monochrome-flag is set it'll just set the variables blank.
To avoid having a if-else for every print statement - that'd be messy.
What breaks with email and how can I easily test things when trying alternatives?
from dockcheck.
I'm still intrigued how you're using this and what's causing errors.
Looked into swapping all printf's to variables, that'd mean it would look like this:
# currently:
printf "\n\033[0;33mContainers with updates available:\033[0m\n"
# with variables:
printf "\n%bContainers with updates available:%b\n" "$c_yellow" "$c_reset"
Or something similar, where the variables would just be set to "" if monochrome option was toggled. Would that make a difference in your use case?
from dockcheck.
@mag37 First: Your solution would work. I'm guessing you assign the escape sequences to $c_yellow etc and if the script is started with a -m
monochrome argument you reassign $c_yellow="" or something to that effect?
That would take care of my issue just fine.
To explain how my issue comes to be:
I'm using a bash wrapper script to call dockcheck.sh as cronjob. The wrapper script will direct the output of dockcheck.sh
into a temporary file, measure the runtime, parse the output for actual updates and when there are any, send the content of that file via mail. After that the content of the temporary file is appended to a permanent logfile and itself deleted.
This means that the shell color escape sequences are sent via mail and my mail client doesn't know what to do with them so they're displayed as raw bytes:
checking for docker image updates: Mon Dec 11 00:30:01 CET 2023
. . . . . . . . . . . . . . . .
ESC[0;32mContainers on latest version:ESC[0m
bookstack
from dockcheck.
Just added a new branch, will test it some more before pushing to main. If you can and want to try it, please do and report if it suits your case :)
Edit: Sorry, didnt manage to push a monochrome flag/option yet. I'll get to it tomorrow.
Edit: Some bedside commits and its there. Option added.
from dockcheck.
Good morning :)
I tested the printf_rework branch and it does what it should, the escape characters are gone. Note that I wasn't able to test all variants of output but the principle surely works.
thanks!
from dockcheck.
Thank you for testing and giving feedback! And thank you for bringing up the suggestion in the first place.
I'll merge it with main in a minute, just gonna do some minor cleaning while I'm on it.
from dockcheck.
Related Issues (20)
- [FEATURE REQUEST] email notification (patch included) HOT 3
- Only update container if the new container is X days old HOT 6
- [Feature Request] Update docker-compose stacks and/or Respect docker-compose "depends_on" HOT 11
- Raspberry Pi - Cannot install regctl HOT 3
- [chore] forgot to add the v0.3.2 branch :) HOT 1
- [Feature] Integration for pushbullet support - script attached HOT 3
- Add capability to authenticate with docker account when pulling images HOT 5
- [FEATURE REQUEST] save preference regarding updates (git/curl) HOT 1
- [FEATURE REQUEST] Add option do define/use multiple .env-files HOT 10
- Progress bar fails with -s option HOT 3
- [FEATURE REQUEST] Automatically download latest in use notification add-on HOT 3
- [Feature] Add -v flag for version number printing of dockcheck HOT 1
- [FEATURE REQUEST] Add Link to GitHub repo HOT 3
- Show current/available image version HOT 4
- [FEATURE REQUEST] Telegram notification HOT 3
- [FEATURE REQUEST] Minimal Output HOT 6
- Readme: add install instructions HOT 5
- [Feature Request] - Web Interface Productivity Improvements / Updates Suggestions HOT 2
- Idea: package the repo into an container HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dockcheck.