.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "ENV2 1" .TH ENV2 1 "2018-02-18" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" env2 \- Converts environment variables to various script languages. .SH "SYNOPSIS" .IX Header "SYNOPSIS" \&\fBenv2\fR \-from \fI\s-1SHELL\s0\fR \-to \fI\s-1SHELL\s0\fR [\-o \fI\s-1DESTINATION_FILE\s0\fR] \fI\s-1SOURCE_FILE\s0\fR .PP \&\fBenv2\fR \-\-save [\s-1FILE\s0] .PP \&\fBenv2\fR # displays help .SH "DESCRIPTION" .IX Header "DESCRIPTION" Do you prefer running bash while the rest of the team runs tcsh? Or perhaps you learned csh and the system administrators only know ksh. What happens when they (or you) supply an initialization script to source? If any of these situations sounds familiar, then this may be the script for you. .PP \&\fBenv2\fR takes shell scripts of one flavor in and spits out scripts effectively equivalent in another dialect. We say \*(L"effectively equivalent\*(R" because it does not translate syntax such as \fBif\fR/\fBelse\fR statements. Instead, the original (source) script is evaluated to determine what environment variables it modifies, and the effective values of those variables are simply expressed in the syntax of the destination script's dialect. Typically, this is all you really need for scripts that modify the environment. .PP \&\s-1NOTE:\s0 If you need to the conditionals and for-loops to be used for different situations (e.g. different host architectures), then simply use this script repeatedly as needed. .PP Future extensions may include \fBaliases\fR or . Supported languages currently include: \fBbash\fR, \fBcsh\fR, \fBksh\fR, \fBmodulecmd\fR, \fBperl\fR, \fBplist\fR, \&\fBsh\fR, \fBtclsh\fR, \fBtcsh\fR, \fBvim\fR, \fByaml\fR, and \fBzsh\fR. .PP \&\s-1NOTE:\s0 The file version is identified by an internally computed \s-1SHA1\s0 hash similar to the way \fBgit\fR does versioning. If you get a warning message about inconsistent hash, it means that somebody modified the file without updating the \f(CW$SHA\fR variable. .SH "OPTIONS" .IX Header "OPTIONS" .IP "\fB\-all\fR" 4 .IX Item "-all" Include all variables rather than just those that changed. See \fB\-diff\fR. .IP "\fB\-clear\fR" 4 .IX Item "-clear" Resets the ignore list to almost completely empty except for the generally dangerous environment list. .Sp See \fB\-ignore\fR, \fB\-reset\fR, and \fB\-unsafe_clear\fR. .IP "\fB\-diff\fR" 4 .IX Item "-diff" Only include those variables whose values are different as a result of sourcing the specified input script. This is the default action. .IP "\fB\-from\fR \s-1DIALECT\s0" 4 .IX Item "-from DIALECT" The dialect to translate from. If not present, then the input file is examined for a #! line. If that fails, the \fB\s-1SHELL\s0\fR environment variable is examined. If that fails, we default to \fBbash\fR (Hey, I had to choose something, and \fBbash\fR is the default Linux shell of choice). .IP "\fB\-help\fR" 4 .IX Item "-help" This built-in documentation. Written in \s-1POD\s0 so that you can also have it in \s-1HTML, PDF, RTF,\s0 plain text or as a man page. .IP "\fB\-ignore\fR \s-1VARLIST\s0" 4 .IX Item "-ignore VARLIST" Comma separated list of variables to ignore. By default, \fBenv2\fR starts with the list set to .Sp .Vb 1 \& _,ENV,ENV2,OLDPWD,SHLVL .Ve .Sp See also \fB\-clear\fR, \fB\-reset\fR and \fB\-unsafe_clear\fR. .IP "\fB\-ignored\fR" 4 .IX Item "-ignored" Lists variables that will be ignored. Useful if you are uncertain and want to clarify things before proceeding. .IP "\fB\-o\fR [\fI\s-1FILE\s0\fR]" 4 .IX Item "-o [FILE]" Specifies a \fI\s-1FILE\s0\fR to save the results in. By default results are sent to \s-1STDOUT.\s0 If you leave off the \fI\s-1FILE\s0\fR, the filename will be \f(CW\*(C`env2.\*(C'\fR\fB\f(CB$SHELL\fB\fR. .IP "\fB\-profile\fR [\fI\s-1FILE\s0\fR]" 4 .IX Item "-profile [FILE]" Specifies a file that contains the starting environment. Defaults to \f(CW\*(C`.env2profile\*(C'\fR. Searches for the file in the current directory or \f(CW$HOME\fR if path not specified. .IP "\fB\-reset\fR" 4 .IX Item "-reset" Resets the ignore list to a minimum set. .Sp See also \fB\-clear\fR, \fB\-ignore\fR and \fB\-unsafe_clear\fR. .IP "\fB\-save\fR [\s-1FILE\s0]" 4 .IX Item "-save [FILE]" Saves the environment in a perl format. By default saves to env2.pl. Internally, this option is invoked as part of the conversion process and saves an intermediate file to /tmp/env2.$$.pl. .IP "\fB\-sha1\fR" 4 .IX Item "-sha1" Displays the \s-1SHA1\s0 version identifier. Use this to see if script has been modified since last updated. .IP "\fB\-to\fR \s-1DIALECT\s0" 4 .IX Item "-to DIALECT" The dialect to translate to. If not supplied, the \fB\s-1SHELL\s0\fR environment variable is examined. If that fails, we default to \fBbash\fR (Hey, I had to choose something, and \fBbash\fR is the default Linux shell of choice). .IP "\fB\-uniq\fR \fI[\s-1PATHLIST\s0]\fR" 4 .IX Item "-uniq [PATHLIST]" Ensure that each path variable specified in \fI\s-1PATHLIST\s0\fR contains a unique colon separated list. Default is to apply this to common path variables: .Sp .Vb 5 \& MANPATH \& PATH \& LD_LIBRARY_PATH \& DYLD_LIBRARY_PATH \& PERL5LIB .Ve .IP "\fB\-unsafe_clear\fR" 4 .IX Item "-unsafe_clear" Resets the ignore list to completely empty. This is potentially dangerous because allows inclusion of dangerous environment variables that the user should not touch. These dangerous variables can have an adverse affect on operation of \s-1UNIX.\s0 .Sp See also \fB\-clear\fR, \fB\-ignore\fR and \fB\-reset\fR. .IP "\fB\-\-version\fR" 4 .IX Item "--version" Display version of script. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" \&\s-1ENV2\s0 environment variable contains default command-line arguments if defined. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" To support \s-1YAML,\s0 this script uses the \s-1CPAN YAML\s0 module. .SH "EXAMPLES" .IX Header "EXAMPLES" .Vb 2 \& # Simple conversion \& env2 \-from ksh \-to csh \-o setup.csh setup.ksh \& \& # Create a modules cmd for a new xyz tool version 1.0 \& TOOL_SETUP=$TOOLS/vendor_dir/xyz_tool/xyz\-1.0/setup.script \& MDLDIR=$TOOLS/modules/tools/xyz \& env2 \-from sh \-to modulecmd \-o $MDLDIR/1.0 $TOOL_SETUP \& \& # Dynamically use a script for another shell to set environment \& eval \`env2 \-from ksh \-to $SHELL \-o setup.csh setup.ksh\` .Ve .SH "COPYRIGHT/LICENSE" .IX Header "COPYRIGHT/LICENSE" env2 is copyright (C) 2003\-2008 David C Black. All rights reserved. This code may is hereby made available under Apache 2.0 licensing. .SH "AUTHOR" .IX Header "AUTHOR" David C. Black