Welcome, guest | Sign In | My Account | Store | Cart

It Open by default a uuid-like temporary file. There is no actual was to modify the name, but assuming the implementation of ZenityShellEval imply a limited acces to shell, you might recuperate information from shell or futur adding to transfer a name or simple renaming the uuid-like file-name... This is to prevent auto-execution of a script from canned-design by playing with without having all clearly create your shell script and/or having fully pseudo-code explained and having confirmation of your design work...

Initially, the shell Editor look like this : is: Image of Zenity Shell In action

The dependency are simple, it require My GitHub Fnct.D project, available here: [link](https://github.com/priendeau/Fnct.d) to be installed inside /etc/init.d/Fnct.D like this

git clone https://github.com/priendeau/Fnct.d /etc/init.d/Fnct.D

and loading the Lib first:

. /etc/init.d/Fnct.D/fnct_lib

Bash, 200 lines
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
unset ZenityShellEval ;
function ZenityShellEval()    
{ 
 local __call_locality=( ZSE ZenityShellEval ) ;
 local ArrayArg=( $* ) ; 
 local Arg0=${ArrayArg[0]}              ;
 local IntSleep=${ZSESleepInterval:=5}  ;
 local IntFontSize=${ZSEFontSize:=12}   ; 
 local IsEditField=${ZSEEditable:=True} ; 
 local IsAddFootPrint=${ZSEAddFootPrint:=True} ; 
 local StrTitle=${ZSEZenityTitle:='Shell Evaluation command'} ;
 local StrFileName=${ZSEFileName:=None} ;
 local StrDateFormat=${ZSEDateFormat:=%Y%m%d-%H:%M:%S,%s}
 local IntDefaultModeExec=${ZSEChmodFileExec:=775} ;
 local StrFilePath=${ZSEPathStorage:=./} ; 
 local IntWidth=${ZSEWindowWidth:=640} ;
 local IntHeight=${ZSEWindowHeight:=400} ;
 local IsLoopOnSucc=${ZSELoopOnSucc:=True} ; 
 local IsCheckSumOnly=${ZSECheckSumTest:=False} ; 
 
 ### Note: f1161962-0ad8-11e3-b166-001b3875b29c 
 ### 
 ### Title : Variable Forwarding Example in BoolVarTestVarCreation & mutation 
 ### of BoolVarTestVarCreation from True/False test into None
 ### 
 ### BoolVarTestVarCreation for substitution of StrFileTmp has unidirectionnaly
 ### a uuid-like file name into Pre-fixed Var ZSEFileName:=None for 
 ### affectation inside StrFileName=None, where if this one != None, will 
 ### get the parameter Name Being passed inside StrFileTmp. 
 ### 
 ### - Had consequence:
 ###  - if the file does not exist, an echo > StrFileTmp will be done . 
 ###  - if the file exist, content will be open by Zenity in text-info --editable
 ###  - Selected filename supplied, content will be overwritted and there is 
 ###  no protection mechanism and no verification against file-permission
 ###    - To this, a workaround will store all code generated from this application
 ###    - into sub-directory being made by the command and store-it inside user
 ###      respective home location which is safe and Pre-fixable into 
 ###      your specification, and not-warrented to be correct but designable. 
 ###  
 ### 
 ### - If the variable ZSEFileName is untouched, the content of StrFileTmp will
 ### hold value 'None' and belong to parsed BoolVarTestVarCreation it should 
 ### get it's uuid-like filename, see generated command from parameter below
 ### 
 ### Command : BVTestVarName=StrFileTmp BVTestVarHold='${StrFileName}' BVTestBoolVarName=\${StrFileName} BVTestBoolCase=None BVTestBoolAssertion='$( uuidgen -t )' BVTestScopeTest=local BoolVarTestVarCreation
 ### 
 ### generated code:
 ### local StrFileTmp="${StrFileName}" ; 
 ### if [ "${StrFileName}" == "None" ] ; then 
 ###  StrFileTmp=$( uuidgen -t ) ; 
 ### fi
 ### 
 ### Which is making sense. 
 ### 
 ### Also Note f1161962-0ad8-11e3-b166-001b3875b29c introduce explanation on mutation of BoolVarTestVarCreation from True/False test into None and moving uuid-file-id variable inside BVTestBoolAssertion
 ### 
 ### 
 eval $( BVTestVarName=StrFileTmp \
         BVTestVarHold='${StrFilePath}/${StrFileName}' \
         BVTestBoolVarName=\${StrFileName} \
         BVTestBoolCase=None \
         BVTestBoolAssertion='${StrFilePath}/$( uuidgen -t )' \
         BVTestScopeTest=local \
         BoolVarTestVarCreation ) ; 
 
 local StrSwitchMessages="${StrSwitchesShow}${StrStartSwitches}\n${StrGetMsgSwitches}\n${StrListMsgSwitches}\n${StrCompWordMsgSwitches}\n" ;
 

 function __main_Editor()
 {
  local __call_locality=( Editor __main_Editor ) ;
  local Arg0=${ArrayArg[0]} ;
  local ArrayArg=( $* ) ;
  test ! -e ${StrFileTmp} && echo "" > ${StrFileTmp} ; 
  
  local res=1 ; 
  local shell_res=0 ; 
  local shell_quit=0 ; 
  eval $( BVTestVarName=StrEditableAttr \
          BVTestVarHold='--editable' \
          BVTestBoolVarName=\${IsEditField} \
          BVTestBoolCase=False \
          BVTestBoolAssertion='' \
          BVTestScopeTest=local \
          BoolVarTestVarCreation ) ; 
  
  
  while [ ${res} -eq 1 -a ${shell_quit} -eq 0 ] ; do 
   CmdEval=$( zenity \
              --text-info ${StrEditableAttr} \
              --font=${IntFontSize} \
              --filename=${StrFileTmp} \
              --title="${StrTitle}" \
              --width=${IntWidth} \
              --height=${IntHeight} ) ; 
   res=$? ; 
   if [ ${res} -ne 1 ] ; then 
    ### 
    ### FootPrint Section
    ###
    ###
      function _NoFootPrint()
      {
        echo -ne "###\n### No FootPrint Added, see Prefixed-Var ZSEAddFootPrint from ZenityShellEval\n###\n###\n###\n###\n###\n###\n###\n###\n###\n" ; 
      }
      function _FootPrint()
      {
        local StrUUID=$( uuidgen -t ) ; 
        local StrSha1Sum=$( echo "${CmdEval}" | sha1sum | cut -d ' ' -f 1)
        local StrSize=$( echo "${CmdEval}" | wc -c ) ; 
        local StrNbWord=$( echo "${CmdEval}" | wc -w ) ; 
        local StrDateConfirm=$( GODFormat='${StrDateFormat}' GetOtherDate )
        echo -ne "###\n### FootPrint Added, see Prefixed-Var ZSEAddFootPrint from ZenityShellEval\n###\n\n###File:${StrFileTmp}\n###UUID-TIME-MARKER:${StrUUID}\n###Date: ${StrDateConfirm}\n###Sha1Sum: ${StrSha1Sum}\n### Size:${StrSize}\n### NbWord: ${StrNbWord}\n\n" ; 
      }
      function _DetectFootPrint()
      {
       local IntFootPrintDetection=$( echo -ne "${CmdEval}" | head -n 11 | egrep -ic "FootPrint" ) ;
       eval $( BVTestVarName=StrFootPrintMark BVTestVarHold='$( StrDateFormat=${StrDateFormat} CmdEval=${CmdEval} _FootPrint )' BVTestBoolVarName=\${IsAddFootPrint} BVTestBoolCase=False BVTestBoolAssertion='$( _NoFootPrint )' BVTestScopeTest=local BoolVarTestVarCreation ) ;
      }
      
      eval $( BVTestVarName=StrFootPrintMark BVTestVarHold='$( StrDateFormat=${StrDateFormat} CmdEval=${CmdEval} _FootPrint )' BVTestBoolVarName=\${IsAddFootPrint} BVTestBoolCase=False BVTestBoolAssertion='$( _NoFootPrint )' BVTestScopeTest=local BoolVarTestVarCreation ) ;       
      
    ###
    ### End FootPrint
    ###
    
    
    echo """${StrFootPrintMark}\n${CmdEval}""" > ${StrFileTmp} ; 
    chmod 775 ${StrFileTmp} ; 
    . ${StrFileTmp} ; 
    shell_res=$?
    if [ ${shell_res} -eq 1 ] ; then 
     echo -ne "\n\n\tUser Shell evaluation reported error\n\n" > /dev/stderr ; 
     res=1 ; 
     shell_res=1 ; 
    fi 
   else 
    echo -ne "\n\n\tUser cancel the test.\n\n" > /dev/stderr ; 
    shell_quit=1 ; 
   fi ; 
   sleep ${IntSleep} ; 
   test ${res} -eq 0 -a ${shell_res} -eq 0 && eval $( BVTestVarName=res BVTestVarHold='0' BVTestBoolVarName=\${IsLoopOnSucc} BVTestBoolCase=False BVTestBoolAssertion='1' BVTestScopeTest=local BoolVarTestVarCreation ) ; 
  done
  echo -ne "\n\tQuitting Function :${__call_locality[1]}\n\n" > /dev/stderr ;  
 }
 function __main_CheckSum()
 {
		local __call_locality=( CheckSum __main_CheckSum ) ;
		local Arg0=${ArrayArg[0]} ;
		local ArrayArg=( $* ) ;
  local CheckSumFile=$( cat ${StrFilePath}/${StrFileName} | grep -v "^###" | sha1sum | cut -d ' ' -f 1  ) ; 
  local CheckSumIdentity=$( cat ${StrFilePath}/${StrFileName} | grep "^###Sha1Sum:" | cut -d ' ' -f 2  | sed 's/[\ \t]//g' ) ;
  echo -ne "File: ${CheckSumFile}\nFootprint: ${CheckSumIdentity}\n" > /dev/stderr ; 
  if [ ${CheckSumFile} == ${CheckSumIdentity} ] ; then 
   echo -ne "file-shasum:${StrFilePath}/${StrFileName}:MATCH\n" ; 
  else
   echo -ne "file-shasum:${StrFilePath}/${StrFileName}:FAILED\n" ; 
  fi 
 }

 function __main_StartServices()
 {
		local __call_locality=( Main __main_StartServices ) ;
		local Arg0=${ArrayArg[0]} ;
		local ArrayArg=( $* ) ; 
  if [ "${IsCheckSumOnly}" == "True" ] ; then 
   StrFilePath=${StrFilePath} StrFileName=${StrFileName} __main_CheckSum ; 
  else
  eval $( VTVValueEntry=StrFileTmp,StrTitle,StrDateFormat,IntSleep,IntFontSize,IsEditField,IntWidth,IntHeight,IntDefaultModeExec,IsEditField,IsAddFootPrint,IsLoopOnSucc,IsCheckSumOnly\
          VTVIsValueReAssign=True \
          VTVIsValueToConvert=False \
          VTVIsArrayStyleInsert=True \
          ValueToVariable ) __main_Editor 
  fi


 }
 
 if [ "${Arg0:=--startservices}" == "--help"	] ; then 
			GetVarReference ${__call_locality[1]} ; 
			echo -ne "${StrSwitchMessages}" > /dev/stderr ; 
	elif [ "${Arg0:=--startservices}" == "--get" ] ; then 
		eval """local ArgGet=\${${ArrayArg[1]}}""" ; 
		echo -ne """${ArgGet}\n""" ;
	elif [ "${Arg0:=--startservices}" == "--list" ] ; then 
		eval $( __GetVarReferenceList ) ;
 elif [ "${Arg0:=--startservices}" == "--compword" ] ; then 
		eval $( __GetVarReferenceCompWord ) ;
 elif [ "${Arg0:=--startservices}" == "--startservices" ] ; then 
  eval $( VTVIsArrayStyleInsert=True \
  VTVValueEntry=StrFileTmp,StrTitle,StrDateFormat,IntSleep,IntFontSize,IsEditField,IntWidth,IntHeight,IntDefaultModeExec,IsAddFootPrint,IsLoopOnSucc,IsCheckSumOnly \
  VTVIsValueReAssign=True \
  VTVIsValueToConvert=False \
  VTVIsArrayStyleInsert=True \
  ValueToVariable ) __main_StartServices
 fi


}

Uses of certains function braced or not with eval, or eval $( ... ), are presented inside my github [link](https://github.com/priendeau/Fnct.d) and function like :

  • BoolVarTestVarCreation
  • ValueToVariable Are helper-function. An helper-function by definition of this library are function can be called with --help. Like BoolVarTestVarCreation is an if generator, it generate an if ..

See the Help: BoolVarTestVarCreation --help

Output:

Help:

Function BoolVarTestVarCreation Default Variable Value: Variable BVTestVarName , Default Value:StrAttrHold Variable BVTestVarHold , Default Value:CONTENT Variable BVTestBoolVarName , Default Value:IsVarShould Variable BVTestBoolCase , Default Value:False Variable BVTestBoolAssertion , Default Value:"" Variable BVTestScopeTest , Default Value:local Variable BVTestIfType , Default Value:String Variable BVTestIfOp , Default Value:== Variable BVTestDisplayIf , Default Value:False Following switch are available:

--startservices Start the application normally.
--get       Return value of Internal Variable.
--list      List all Internal Pre-fixed Variable available to query or get.

And Executing the function BoolVarTestVarCreation will generate on screen an if-case statement:

Sample generated

--------------------------------------------------------------

local StrAttrHold="CONTENT" ; if [ "IsVarShould" == "False" ] ; then StrAttrHold="" ; fi

--------------------------------------------------------------

Where you can see inside the help provided with --help, you can replace inside this is , StrAttrHold="CONTENT" with pre-fixed variable BVTestVarName and BVTestVarHold :

BVTestVarName=IsNewtest BVTestVarHold='False' BoolVarTestVarCreation ( will output ) :

Sample generated

--------------------------------------------------------------

local IsNewtest="False" ; if [ "IsVarShould" == "False" ] ; then IsNewtest="" ; fi

--------------------------------------------------------------

Sound's great for another stone in a soup-recipe !