<commit_before>shim_command() {
  local plugin_name=$1
  local executable_path=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path
  ensure_shims_dir

  generate_shim_for_executable $plugin_name $executable_path
}

reshim_command() {
  local plugin_name=$1
  local full_version=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path
  ensure_shims_dir

  if [ "$full_version" != "" ]; then
    # generate for the whole package version
    generate_shims_for_version $plugin_name $full_version
  else
    # generate for all versions of the package
    local plugin_installs_path=$(asdf_dir)/installs/${plugin_name}

    for install in ${plugin_installs_path}/*/; do
      local full_version_name=$(echo $(basename $install) | sed 's/ref\-/ref\:/')
      generate_shims_for_version $plugin_name $full_version_name
    done
  fi
}


ensure_shims_dir() {
  # Create shims dir if doesn't exist
  if [ ! -d $(asdf_dir)/shims ]; then
    mkdir $(asdf_dir)/shims
  fi
}


write_shim_script() {
  local plugin_name=$1
  local executable_path=$2
  local executable_name=$(basename $executable_path)
  local plugin_shims_path=$(get_plugin_path $plugin_name)/shims
  local shim_path=$(asdf_dir)/shims/$executable_name

  if [ -f $plugin_shims_path/$executable_name ]; then
    cp $plugin_shims_path/$executable_name $shim_path
  else
    echo """#!/usr/bin/env bash
exec $(asdf_dir)/bin/private/asdf-exec ${plugin_name} ${executable_path} \"\$@\"
""" > $shim_path
  fi

  chmod +x $shim_path
}


generate_shim_for_executable() {
  local plugin_name=$1
  local executable=$2
  local plugin_path=$(get_plugin_path $plugin_name)

  check_if_plugin_exists $plugin_path

  IFS=':' read -a version_info <<< "$full_version"
  if [ "${version_info[0]}" = "ref" ]; then
    local install_type="${version_info[0]}"
    local version="${version_info[1]}"
  else
    local install_type="version"
    local version="${version_info[0]}"
  fi

  write_shim_script $plugin_name $executable
}


generate_shims_for_version() {
  local plugin_name=$1
  local full_version=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path

  IFS=':' read -a version_info <<< "$full_version"
  if [ "${version_info[0]}" = "ref" ]; then
    local install_type="${version_info[0]}"
    local version="${version_info[1]}"
  else
    local install_type="version"
    local version="${version_info[0]}"
  fi

  local install_path=$(get_install_path $plugin_name $install_type $version)

  if [ -f ${plugin_path}/bin/list-bin-paths ]; then
    local space_seperated_list_of_bin_paths=$(
      export ASDF_INSTALL_TYPE=$install_type
      export ASDF_INSTALL_VERSION=$version
      export ASDF_INSTALL_PATH=$install_path
      bash ${plugin_path}/bin/list-bin-paths
    )
  else
    local space_seperated_list_of_bin_paths="bin"
  fi

  IFS=' ' read -a all_bin_paths <<< "$space_seperated_list_of_bin_paths"

  for bin_path in "${all_bin_paths[@]}"; do
    #TODO check if it's actually an executable file
    for executable_file in $install_path/$bin_path/*; do
      # because just $executable_file gives absolute path; We don't want version hardcoded in shim
      local executable_path_relative_to_install_path=$bin_path/$(basename $executable_file)
      write_shim_script $plugin_name $executable_path_relative_to_install_path
    done
  done
}<commit_msg>Add check to ensure file is an executable in generate_shims_for_version function.<commit_after>shim_command() {
  local plugin_name=$1
  local executable_path=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path
  ensure_shims_dir

  generate_shim_for_executable $plugin_name $executable_path
}

reshim_command() {
  local plugin_name=$1
  local full_version=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path
  ensure_shims_dir

  if [ "$full_version" != "" ]; then
    # generate for the whole package version
    generate_shims_for_version $plugin_name $full_version
  else
    # generate for all versions of the package
    local plugin_installs_path=$(asdf_dir)/installs/${plugin_name}

    for install in ${plugin_installs_path}/*/; do
      local full_version_name=$(echo $(basename $install) | sed 's/ref\-/ref\:/')
      generate_shims_for_version $plugin_name $full_version_name
    done
  fi
}


ensure_shims_dir() {
  # Create shims dir if doesn't exist
  if [ ! -d $(asdf_dir)/shims ]; then
    mkdir $(asdf_dir)/shims
  fi
}


write_shim_script() {
  local plugin_name=$1
  local executable_path=$2
  local executable_name=$(basename $executable_path)
  local plugin_shims_path=$(get_plugin_path $plugin_name)/shims
  local shim_path=$(asdf_dir)/shims/$executable_name

  if [ -f $plugin_shims_path/$executable_name ]; then
    cp $plugin_shims_path/$executable_name $shim_path
  else
    echo """#!/usr/bin/env bash
exec $(asdf_dir)/bin/private/asdf-exec ${plugin_name} ${executable_path} \"\$@\"
""" > $shim_path
  fi

  chmod +x $shim_path
}


generate_shim_for_executable() {
  local plugin_name=$1
  local executable=$2
  local plugin_path=$(get_plugin_path $plugin_name)

  check_if_plugin_exists $plugin_path

  IFS=':' read -a version_info <<< "$full_version"
  if [ "${version_info[0]}" = "ref" ]; then
    local install_type="${version_info[0]}"
    local version="${version_info[1]}"
  else
    local install_type="version"
    local version="${version_info[0]}"
  fi

  write_shim_script $plugin_name $executable
}


generate_shims_for_version() {
  local plugin_name=$1
  local full_version=$2
  local plugin_path=$(get_plugin_path $plugin_name)
  check_if_plugin_exists $plugin_path

  IFS=':' read -a version_info <<< "$full_version"
  if [ "${version_info[0]}" = "ref" ]; then
    local install_type="${version_info[0]}"
    local version="${version_info[1]}"
  else
    local install_type="version"
    local version="${version_info[0]}"
  fi

  local install_path=$(get_install_path $plugin_name $install_type $version)

  if [ -f ${plugin_path}/bin/list-bin-paths ]; then
    local space_seperated_list_of_bin_paths=$(
      export ASDF_INSTALL_TYPE=$install_type
      export ASDF_INSTALL_VERSION=$version
      export ASDF_INSTALL_PATH=$install_path
      bash ${plugin_path}/bin/list-bin-paths
    )
  else
    local space_seperated_list_of_bin_paths="bin"
  fi

  IFS=' ' read -a all_bin_paths <<< "$space_seperated_list_of_bin_paths"

  for bin_path in "${all_bin_paths[@]}"; do
    #TODO check if it's actually an executable file
    for executable_file in $install_path/$bin_path/*; do
      # because just $executable_file gives absolute path; We don't want version hardcoded in shim
      local executable_path_relative_to_install_path=$bin_path/$(basename $executable_file)
      write_shim_script $plugin_name $executable_path_relative_to_install_path
      if [ -x $executable_path_relative_to_install_path ]; then
          write_shim_script $plugin_name $executable_path_relative_to_install_path
      fi
    done
  done
}
{'fraction_non_alphanumeric': 0.10963549025148348, 'fraction_numerical': 0.005086182537439954, 'mean_word_length': 4.769356153219234, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7354023', 'n_tokens_mistral': 2476, 'n_tokens_neox': 2393, 'n_words': 494}