« first day (2179 days earlier)      last day (870 days later) » 

3:59 AM
Start your command with LC_ALL=Cso the output is in english.
 
 
3 hours later…
6:45 AM
@ThePirate42 the error message looks like you are not using Bash at all; see Difference between sh and bash
the syntax looks rather clumsy as such; I would definitely refactor it to avoid the long sequence inside [[ ... ]]
maybe like this
case :$PATH: in
    *:$HOME/bin:*) ;;
    *) if [[ $UID -ge 1000 ]] && [[ -d "$HOME"/bin ]]; then
        export PATH="$PATH:$HOME/bin"
      fi;;
esac
avoiding grep and doing this purely with shell built-ins is the big win here (but as such really a micro-optimization); the other changes are mainly stylistic
but again, the usual reason you get a syntax error for something which is syntactically valid is that you run it with the wrong interpreter
if that's not it, probably try running it with bash -x and examine the output
 
7:07 AM
@ThePirate42 ohhh indeed /etc/proifile.d is being run by sh, not Bash
the POSIX syntax for the same would use [ .,, ] instead of the Bash-only double square brackets
but $UID is not defined in sh so you have to get that from somewhere
maybe like this then
case :$PATH: in
    *:$HOME/bin:*) ;;
    *) if [ $(id -u) -gt 1000 ] && [ -d "$HOME/bin" ]; then
        PATH="$PATH:$HOME/bin"
      fi;;
esac
as an aside I don't think you need to export this variable separately; pretty sure the system already does that for you (file a bug report if not!)
one reason to prefer the case syntax is that you then bypass anything which uses an external command or examines the disk directly if the PATH already contains the directory
(though of course the long if could be refactored to do that as well)
 
 
1 hour later…
8:35 AM
I managed to get it working, this is an excerpt from new code.

printf "%b" "${Wh}$narrate${Nc}"; tput sc
while kill -0 $pid 2>/dev/null; do
local i=$(((i + $charwidth) % ${#spin}))
tput rc; tput cuf 1
printf "%b" "${Cy}${spin:$i:$charwidth}\b${nc}"
sleep .1
done
 
 
2 hours later…
10:07 AM
@ThePirate42 the really tiny and low-contrast screen shot is quite distracting; please review meta.stackoverflow.com/questions/303812/…
 
10:52 AM
@Queen k but enjoined from posting another cv-pls
 
 
3 hours later…
1:22 PM
@tripleee when using recursion in bash scripts can I make some variables scope only to the current function being executed ?
 
1:40 PM
@louigi600 local makes a variable local to the current function, or do you mean somehow expose it to recursive calls to the same function?
 
I think the first:
I want the variables I'm using the the recursion to be local so I get the correct values when running the tail recursion
 
 
1 hour later…
2:43 PM
When local is used within a function, it causes the variable name
to have a visible scope restricted to that function and its children.
I'm not sure it's going to behave as I expect
the problem lies in "and its children"
the children are recursive calls to the same function
I have found a workarounf for the problem ... but I was curious to see if there is a more elegant solution
 
3:26 PM
@louigi600 hmm, I don't think so, you can't prevent it from leaking to children ... I guess the usual solution would be to pass it in as a parameter if you need every function invocation to have its own value
 

« first day (2179 days earlier)      last day (870 days later) »