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

Colors in `cbsd jls` prevent loop from working #364

Closed
moviuro opened this issue Dec 12, 2018 · 4 comments

Comments

@moviuro
Copy link
Contributor

@moviuro moviuro commented Dec 12, 2018

FreeBSD version ( uname -a ):

% uname -a
FreeBSD castle-of-hearts.xxx.xx 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64

CBSD version ( cbsd version ): 12.0.3

Following code does not work:

# for j in $(cbsd jls | awk '{ if (NR != 1) { print $1 }}'); do cbsd jset jname=$j ver=12.0 ; done                                                                                 
No such jail: ampache
[...]

Because of

printf "${CYAN}"
:

# cbsd jls | awk '{ if (NR != 1) { print $1 }}' | hexdump -C                                       
00000000  1b 5b 30 6d 1b 5b 30 3b  33 36 6d 61 6d 70 61 63  |.[0m.[0;36mampac|
00000010  68 65 0a 1b 5b 30 6d 1b  5b 30 3b 33 36 6d 68 61  |he..[0m.[0;36mha|
[...]

Solutions:

  • add a switch to disable/enable color
@olevole

This comment has been minimized.

Copy link
Collaborator

@olevole olevole commented Dec 12, 2018

Hello @moviuro ! cbsd jset in hard way =) ? How are you ? and cbsd auto-completeion project ;) glad to see you)
It seems that of all the possible options that cdsd offers you, you have chosen the most difficult.

cbsd can use jname as mask for mass-command, so you can do something like:

cbsd jset jname='*' ver=native
cbsd jset jname='*' ver=native astart=0 devfs_ruleset=4   [..]
cbsd jexec jname='jail*' file -s /bin/sh
cbsd pkg jname='myja*l*' mode=install  ca_root_nss nss
cbsd jstop jname='*'
cbsd jstart jname='lala*'

If you want to display only certain fields in 'cbsd jls', you can use 'header=0' and 'display=', e.g:

cbsd jls header=0 display=jname,ver,astart

besides this, you can get by one command list of all jails (sorted in boot order sequence) via 'cbsd jorder'

e.g:

for i in $( cbsd jorder ); do
   echo $i
done

And finally you can turn off ANSICOLOR via NOCOLOR environment variable by env or global env (via .cshrc, .bashrc, .login, setenv or export )
try this:

env NOCOLOR=1 cbsd jls

or for csh:

setenv NOCOLOR 1
cbsd jls

or for sh/bash (zsh?):

export NOCOLOR=1
cbsd jls

@olevole

This comment has been minimized.

Copy link
Collaborator

@olevole olevole commented Dec 12, 2018

someone also wanted to adjust the color behavior through the configuration file, I think I’ll do it soon

olevole pushed a commit that referenced this issue Dec 14, 2018
now we can use global.conf to disable ansii color, in addition to env(1) var
Issue #364
@olevole

This comment has been minimized.

Copy link
Collaborator

@olevole olevole commented Dec 14, 2018

global.conf has been added for NOCOLOR settings via config file.
will be available in the next 12.0.4 release

@olevole olevole closed this Dec 14, 2018
@olevole

This comment has been minimized.

Copy link
Collaborator

@olevole olevole commented Feb 16, 2019

commited to ports tree: 12.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.