Project

General

Profile

Actions

Bug #30639

closed

hammer prebuild-bash-completion create a directories '~' and '~/.cache' in user's home directory AND stores JSON in a .yml file

Added by Peter Bray about 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
-
Difficulty:
Triaged:
Yes
Team Backlog:
Fixed in Releases:
Found in Releases:
In Kanboard:

Description

Package: rubygem-hammer_cli.noarch 2.1.1-1.el8

Running 'hammer prebuild-bash-completion' create a subdirectory name '~' of the user's home directory and than creates a '.cache' directory under that.

Example: On CentOS 8.2 System (hostname redacted)

[admin@centos8-host ]$ cd
[admin@centos8-host ~]$ touch . # So its lists last
[admin@centos8-host ~]$ ls ltra | tail -1
drwx-----
. 7 admin admin 4096 Aug 12 18:22 .
[admin@centos8-host ~]$ hammer prebuild-bash-completion
environment command is deprecated and will be removed in one of the future versions. Please use puppet-environment command instead.
report command is deprecated and will be removed in one of the future versions. Please use config-report command instead.
[admin@centos8-host ~]$ ls -ltra | tail -1
drwxrwxr-x. 3 admin admin 20 Aug 12 18:22 ~
[admin@centos8-host ~]$ find ./
-ls
67519951 0 drwxrwxr-x 3 admin admin 20 Aug 12 18:22 ./~
100919321 0 drwxrwxr-x 2 admin admin 6 Aug 12 18:22 ./~/.cache
[admin@centos8-host ]$ rm -rfv ./
removed directory './~/.cache'
removed directory './~'

Looking at /usr/share/gems/gems/hammer_cli-2.1.1/lib/hammer_cli/bash/prebuild_command.rb (shown below), either setting cache_file needs to under go tilde (~) expansion before being used passed to dirname(), or another cause needs to be investigated.

Regards,
Peter

module HammerCLI
module Bash
class PrebuildCompletionCommand < HammerCLI::AbstractCommand
def execute
map = HammerCLI::MainCommand.completion_map
cache_file = HammerCLI::Settings.get(:completion_cache_file)
cache_dir = File.dirname(cache_file)
FileUtils.mkdir_p(cache_dir) unless File.directory?(cache_dir)
File.write(File.expand_path(cache_file), map.to_json)

HammerCLI::EX_OK
end
end
end
HammerCLI::MainCommand.subcommand(
'prebuild-bash-completion',
_('Prepare map of options and subcommands for Bash completion'),
HammerCLI::Bash::PrebuildCompletionCommand
)
end

Related issues 1 (0 open1 closed)

Has duplicate Hammer CLI - Bug #31463: hammer(1) bash completion spews errors over the command line - Failure to expand '~' in the default configurationDuplicateActions
Actions

Also available in: Atom PDF