a-shell icon indicating copy to clipboard operation
a-shell copied to clipboard

Command not found

Open ifuchs opened this issue 3 years ago • 7 comments

I have a python script in the bin directory. If I try to run it by typing its name right after starting a shell, it will always fail with “: command not found“. However, it will always work the second and subsequent times.

ifuchs avatar Mar 17 '22 01:03 ifuchs

I've tried, and I cannot reproduce the issue. I have a python script in the bin and it runs when I call it by name, even as the first command in a-Shell.

My python script:

#! python
print("it worked")

holzschu avatar Mar 22 '22 12:03 holzschu

I realize this is not a high priority issue but just to show you what I am talking about, please see the video below. This happens right after I start ashell. The wordle command is a python script in the bin directory.

https://user-images.githubusercontent.com/5650376/159913910-979f2af1-c6bd-4dc1-a0a2-1b32f678b25f.MP4

ifuchs avatar Mar 24 '22 12:03 ifuchs

Can I get the script to give it a try?

holzschu avatar Mar 24 '22 12:03 holzschu

Sure. I deleted most of the words in the valid and sol variables so the post would not be so long but if you want the unedited version I can post it elsewhere.


#! python
import random
import time

letter_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
valid = ["aahed", "aalii"]
sol = ["cigar", "rebut"]
present = []
word_list = valid + sol
conf_word = ['','','','','']
absent_list = []

def update(word, status):
    absent_list.clear()
    if len(sol) == 1:
        print('Solution found: {}'.format(sol[0]))
        return
    for i in range(len(word)):
        if status[i] == 'c':
            if word[i] not in present:
                present.append(word[i])
            if conf_word[i] == '':
                conf_word[i] = word[i]
            try:
                letter_list.pop(letter_list.index(word[i]))
            except:
                pass
            remove_words_c(word[i], i)
        elif status[i] == 'p':
            if word[i] not in present:
                present.append(word[i])
            try:
                letter_list.pop(letter_list.index(word[i]))
            except:
                pass
            absent_list.append([word[i], i])
            remove_words_p(word[i])
        elif status[i] == 'a':
            try:
                letter_list.pop(letter_list.index(word[i]))
            except:
                pass
            absent_list.append([word[i], i])
    remove_words_a(absent_list)
    print(str(len(sol)) + ' words\n',sol)
    if len(sol) == 1:
        print('Solution found: {}'.format(sol[0]))
        return
    print("Our recommendation: {}".format(random.choice(sol)))
    prompt = input("Found (y)?: ")
    if prompt != 'y':
        update(input('Word: '), input('Status: '))
 
def remove_words_c(letter, index):
    pop_list_wl = []
    pop_list_sol = []
    for i in word_list:
        if i[index] != letter:
            try:
                pop_list_wl.append(word_list.index(i))
            except:
                pass
    for i in range(len(pop_list_wl)):
        word_list.pop(pop_list_wl.pop())
    for i in sol:
        if i[index] != letter:
            try:
                pop_list_sol.append(sol.index(i))
            except:
                pass
    for i in range(len(pop_list_sol)):
        sol.pop(pop_list_sol.pop())

def remove_words_p(letter):
    pop_list_wl = []
    pop_list_sol = []
    for i in word_list:
        if letter not in i:
            try:
                pop_list_wl.append(word_list.index(i))
            except:
                pass
    for i in range(len(pop_list_wl)):
        word_list.pop(pop_list_wl.pop())
    for i in sol:
        if letter not in i:
            try:
                pop_list_sol.append(sol.index(i))
            except:
                pass
    for i in range(len(pop_list_sol)):
        sol.pop(pop_list_sol.pop())

def remove_words_a(letters):
    for letter in letters:
        index = letter[1]
        pop_list_wl = []
        pop_list_sol = []
        for i in word_list:
            if letter[0] in i and letter[0] not in present:
                try:   
                    pop_list_wl.append(word_list.index(i))
                except:
                    pass
            elif letter[0] in present and i[index] == letter[0]:
                try:
                    pop_list_wl.append(word_list.index(i))
                except:
                    pass
        for i in range(len(pop_list_wl)):
            word_list.pop(pop_list_wl.pop())
        for i in sol:
            if letter[0] in i and letter[0] not in present:
                try:
                    pop_list_sol.append(sol.index(i))
                except:
                    pass
            elif letter[0] in present and i[index] == letter[0]:
                try:
                    pop_list_sol.append(sol.index(i))
                except:
                    pass
        for i in range(len(pop_list_sol)):
            sol.pop(pop_list_sol.pop())

def compare(guess, solution):
    response = []
    for i in range(len(guess)):
        if guess[i] == solution[i]:
            response.append('c')
        elif guess[i] in solution:
            response.append('p')
        else:
            response.append('a')
    return response

def AI():
    tries = 0
    solution = sol[random.randint(0,len(sol)-1)]
    while len(word_list) != 1:
        guess = word_list[random.randint(0,len(word_list)-1)]
        response = compare(guess, solution)
        update(guess, response)
        tries += 1
    
    print('[{} Tries] Word: {}'.format(tries, word_list[0]))
    return tries

update(input('Word: '), input('Status: '))

ifuchs avatar Mar 24 '22 12:03 ifuchs

I cannot reproduce the issue, even with the same script. This one is a bit of a mystery. image

holzschu avatar Mar 24 '22 12:03 holzschu

I guess it must be something about my environment but I have no idea what that might be.

ifuchs avatar Mar 24 '22 12:03 ifuchs

Strange, since it happens every time I start ashell.

ifuchs avatar Mar 28 '22 01:03 ifuchs