[ast-users] ksh93: memory faults under MacOS 10.9

2014-04-16 Thread j. van den hoff
apologies in advance for this lengthy mail, but I am at a total loss  
currently:


after upgrading my mac from 10.8 to 10.9 today I see regular/frequent  
memory faults of ksh in my setup. this happens with the native ksh coming  
with macos 10.9 (ksh 93u) as well as a binary of ksh 93u+ (but that one  
was compiled under 10.8: my attempt to recompile from the ast-sources  
failed today -- I might come back to the list in that respect, too, but  
first have to look into it a bit).


the memory faults happen in some ksh-functions (actually they are adjusted  
so as to work with bash and zsh as well) which I regularly have used for  
some years now without any problems. together they act as a drop in  
replacement for `cd' (by logging all `cd' actions to a file and  
pattern-matching arguments to subsequent `cd' actions against this  
"database", using the first hit after sorting all entries by frequency of  
occurences. the whole script is ~ 1000 lines, so too long for this mail  
(but I will gladly provide it if there is interest: it even is quite  
useful in my view to rapidly navigate deep directory trees ...). instead I  
include the part where the crash does happen below to give you an idea of  
the context:


8<
function sdname {  ## regex
#--
   # ensure "default" behaviour of `cd' and return immediately
   # if a path to an existing directory is specified
   if [[ -z "$*" ]]; then
  echo "$HOME"
  return
   elif [[ "$*" == "-" ]]; then
  #zsh does not echo a single `-' (why not???), therefore, we here use  
`printf'

  #which works with all three targeted shells.
  printf -- '-\n'
  return
   elif [[ -d "$*" ]]; then
  echo "$*"
  return
   fi
   #
   typeset pat idx awkpat dname match matches

   #treat $* as single argument and protect all `/' to allow them as part  
of

   #the search pattern:
   #
   pat="${*//\//\/}"

   idx=${pat#$sdprefix}
   if [[ $idx != $pat ]] && [[ -z ${idx/+([0-9])} ]]; then
  #look up by numeric index
  idx=${idx:-1}   #`cd =' handled as `cd =1' (or whatever  
prefix is used instead of `=')

  awkpat="NR == $idx"
   else
  #look up by regex pattern matching.
  #remember: the dir names are in field no. 3 in `sdlist'.
  awkpat="\$3 ~ /$pat/"
   fi


   matches=$(echo "$sdlist" |\
  $awk -F"\t" "$awkpat"' {
 sub(/^~/, "'"$HOME"'", $3)
 print $3
  }')

   # select first actually existing directory
   typeset IFS=$'\n'
   for match in $matches; do
  [[ -d $match ]] && {
 dname=$match
 break
  }
   done

   #if `dname' is empty at this point, we simply pass through $*
   #(and let the final `cd' fail ...).
   #
   dname=${dname:-"$*"}
   echo "$dname"
}

function sd {  ## regex
#--
   typeset dname
   typeset IFS=$'\n'

   dname=$(sdname "$*")
   command cd "$dname" 2>/dev/null

   (( $? == 0 )) || {
  typeset -i lines
  lines=$(sdlinecount "$sdlog")
  (( lines > sdlines )) && {
 typeset sdlinesOrig=$sdlines
 ((sdsilent == 1)) || echo "no match so far - extending stack"
 sdirs -l $lines
 dname=$(sdname "$*")
 matches=$(sdirs "$*" | awk -F'\t' 'NR > 1 {print $3}')
 sdirs -l $sdlinesOrig   # reset the stack to original length
 command cd "$dname" 2>/dev/null
 (( $? == 0 )) && {
((sdsilent == 1)) || {
   echo "using first valid match from:"
   echo "$matches"
}
 } || { echo "No matching directory"; return 1; }
  }
   }

   # avoid logging `cd' to one of (home|current|root)-dir, since otherwise
   #
   # -- $HOME would always be at the top of the stack (really undesirable),
   # -- an accidental/reaffirmative `cd .' would artificially increase
   #frequency of visits to the respective directory (matter of taste),
   # -- `/' would be logged although it's always reached as explicit path
   #and the respective stack entry thus would be never used.
   #
   if [[ "$PWD" == !("$HOME"|"$OLDPWD"|/) ]]; then
  typeset entry

  # the following lines work with, _both_, ksh and bash which
  # handle tilde expansion slightly different. when combining both
  # lines into a single one (i.e. avoiding definition of `entry'),
  # tilde expansion cannot be consistently suppressed in both
  # shells. seemingly. (remember, that we need `"' quoting to
  # account for possible blanks in file names).
  #
  entry=${PWD/#$HOME/\~}
  sdnew+="$entry"$'\n'
  sdlog=${sdlog0}${sdnew%$'\n'}

  sdlist=$(sdstack)
   fi
}

function cd {
   sd "$*"
}
8<

where `sdlog' contains newline-separated directory names (those contained  
in the database, i.e. visited previously) and

`sdlist' contains newline-separated records of the format

frequency TAB sorting-ra

Re: [ast-users] ast beta software download update

2014-04-16 Thread Glenn Fowler
sorry for the problems -- this is what happens when 15 year old procedures
change
it will be fixed in about 12 hours when I get back to a terminal


On Wed, Apr 16, 2014 at 3:34 AM, Dr. Werner Fink  wrote:

> On Wed, Apr 16, 2014 at 08:07:11AM +0200, Michal Hlavinka wrote:
> > Hi Glenn,
> >
> > when I try to download it, the files are empty.
>
> Indeed
>
> Werner
>
> --
>   "Having a smoking section in a restaurant is like having
>   a peeing section in a swimming pool." -- Edward Burr
>
___
ast-users mailing list
ast-users@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users


Re: [ast-users] ast beta software download update

2014-04-16 Thread Dr. Werner Fink
On Wed, Apr 16, 2014 at 08:07:11AM +0200, Michal Hlavinka wrote:
> Hi Glenn,
> 
> when I try to download it, the files are empty.

Indeed

Werner

-- 
  "Having a smoking section in a restaurant is like having
  a peeing section in a swimming pool." -- Edward Burr


pgpaB6VIJ4FRN.pgp
Description: PGP signature
___
ast-users mailing list
ast-users@lists.research.att.com
http://lists.research.att.com/mailman/listinfo/ast-users