Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I don't know any ros command, but the following script works. It's quite slow though using rospack list and just checking prefixes (so half filenames will work too).

#!/bin/bash
pkg_file=$1

for i in $(rospack list | awk '{print $2}'); do
   pkg_name=$(basename $i)
   if [[ ${pkg_file} == ${i}* ]]; then
      echo ${pkg_name}
      exit 0
   fi
done

I don't know any ros command, but the following script works. It's quite slow though using rospack list and just checking prefixes (so half filenames will work too).

#!/bin/bash
pkg_file=$1

for i in $(rospack list | awk '{print $2}'); do
   pkg_name=$(basename $i)
   if [[ ${pkg_file} == ${i}* ]]; then
      echo ${pkg_name}
      exit 0
   fi
done

Searching for manifest.xml:

#!/bin/bash
pkg_file=$1
pkg_dir=$(dirname ${pkg_file})

pushd . > /dev/null

cd ${pkg_dir}

while [[ ! -e manifest.xml ]]; do
   cd ..
   if [[ $(pwd) == "/" ]]; then
      break
   fi
done

if [[ -e manifest.xml ]]; then
   echo $(basename `pwd`)
fi

popd > /dev/null
 

I don't know any ros command, but the following script works. It's quite slow though using rospack list and just checking prefixes (so half filenames will work too).

#!/bin/bash
pkg_file=$1

for i in $(rospack list | awk '{print $2}'); do
   pkg_name=$(basename $i)
   if [[ ${pkg_file} == ${i}* ]]; then
      echo ${pkg_name}
      exit 0
   fi
done

Searching for manifest.xml:

#!/bin/bash
pkg_file=$1
pkg_dir=$(dirname ${pkg_file})

pushd . > /dev/null

cd ${pkg_dir}

while [[ ! -e manifest.xml ]]; do
   cd ..
   if [[ $(pwd) == "/" ]]; then
      break
   fi
done

if [[ -e manifest.xml ]]; then
   echo $(basename `pwd`)
fi

popd > /dev/null